目前我正在将数据对象从一个页面传递到另一个页面(在Modal中).
我有8个参数传递给模态视图.
this.firstParam = navParams.get("firstPassed"); this.secondParam = navParams.get("secondPassed"); . . . this.eightParam = navParams.get("eightPassed");
this.data = navParams.getAll(); //something like this
解决方法
你不需要这样做.您可以像下面一样发送所有内容.
注意:声明像DtoMy这样的数据传输对象
DTO-my.ts
export class DtoMy { firstPassed: string; secondPassed: string; //your other properties }
发送
let dtoMy = new DtoMy(); dtoMy.firstPassed= 'firstPassed'; dtoMy.secondPassed= 'secondPassed'; //your other values const myModal = this.modalCtrl.create('MyModalPage',{ data: dtoMy }); myModal.onDidDismiss(data => { }); myModal.present();
接收:
我的模态,page.ts
data :DtoMy; constructor(private navParams: NavParams,private modalCtrl: ModalController) { this.data = this.navParams.get('data'); }