我有一個父頁面和三個子頁面,我正在使用 ionic router-outlet 進行導航:
父頁面.html
<ion-content>
<ion-router-outlet></ion-router-outlet>
</ion-content>
父路由模塊.page.ts
children: [
{
path: 'child-one',
},
{
path: 'child-two',
},
{
path: 'child-three',
}
]
我想通過路由器插座將資料從父頁面傳遞到每個導航的子頁面我該怎么做?
uj5u.com熱心網友回復:
離子路由基本上是由角度路由處理的,所以你必須在這些問題上尋找角度解決方案。
如果這與您的子頁面有關,主要方法是在子頁面的 url 中傳遞字串資料,如下所示:
children: [
{
path: 'child\:myVariable',
}
]
在您的子頁面中:
constructor(private route: ActivatedRoute) {
}
...
ngOnInit() {
const myVar = this.route.snapshot.paramMap.get('myVariable');
}
或者,您可以使用在根目錄中注入的角度服務,您可以在應用程式的任何位置訪問您的資料。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/514975.html
標籤:有角度的打字稿离子框架
上一篇:如何為每場比賽回傳一個新列
