我正在使用 ionic 4。它不接受使用 navparams 接收数据。
这是我的发件人页面方法:
//private route:Router
gotoFinalView(intent) {
this.route.navigateByUrl(`${intent}`, this.destination);
}
接收寻呼线;
//private navParams:NavParams
this.destination = navParams.data;
在 ionic 4 中执行此操作的正确方法是什么。我也不确定 gotoFinalView 方法是否有效。
这就是我解决问题的方法:
我创建了一个带有 setter 和 getter 方法的服务:
import { Injectable } from "@angular/core";
@Injectable({
providedIn: "root"
})
export class MasterDetailService {
private destn: any;
constructor() {}
public setDestn(destn) {
this.destn = destn;
}
getDestn() {
return this.destn;
}
}
在第一页中注入Service和NavController并将其用作;
gotoFinalView(destn) {
this.masterDetailService.setDestn(destn);
this.navCtrl.navigateForward("destn-page");
}
通过以下方式提取最后一页的数据:
constructor(
private masterDetailService: MasterDetailService
) {
this.destination = this.masterDetailService.getDestn();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)