答案 0 :(得分:1)
首先将您的产品添加到阵列
productList = [] as any[];
productList.push(product);
this.navCtrl.push(OrderPage,{ productList: productList});
答案 1 :(得分:0)
在角度中,您可以通过不同的方式将数据传递到其他页面
来自ts文件的通过查询参数(如果参数不是保密的);
this.router.navigate(
['/path'],
{ queryParams: { key1: valu1, key2: value2, key3: value3 }
});
来自html文件
<a [routerLink]="['/path']"
[queryParams]="{ key1: value1, key2: value2, key3: value3 }">
Something </a>
路径就像http://localhost:4200/path?key1=value1&key2=value2&key3=value3
你可以通过
constructor(private route: ActivatedRoute) {
this.sub = this.route.queryParams.subscribe(params => {
this.id = +params['id']; // (+) converts string 'id' to a number
});
}
通过链接到带参数的路径
this.router.navigate(['/path', {key1: value1, key2: value2}]);
通过
检查参数constructor(private route: ActivatedRoute) {
this.sub = this.route.params.subscribe(params => {
this.id = +params['id']; // (+) converts string 'id' to a number
});
}