ionic-team / ionic-team/ionic-framework

bug: missing state property on routerLink

オープン
#19,291 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
package: angular type: bug
主要言語
TypeScript
スター
52.7k
フォーク
13.3k
平均マージ
1日 15時間
マージ済み PR(30日)
51

説明

# Bug Report

**Ionic version:**

[x] **4.x**

**Current behavior:**

state is being ignored.

**Expected behavior:**

state must be set.

**Steps to reproduce:**

**Related code:**
https://angular.io/api/router/RouterLink
page.html
```
...

This doesn't work

...
This works
```

childPage.ts
```
...
constructor(private userDao: UsersDao, private activatedRoute: ActivatedRoute, private router: Router) {}

async ngOnInit() {
this.activatedRoute.params.subscribe(async params => {
const state = this.router.getCurrentNavigation().extras.state;
console.log({ state: this.router.getCurrentNavigation().extras });
if (state && state.user) {
console.log("State found");
this.user = state.user;
} else {
console.log("State not found");
const id = params.id;
this.user = await this.userDao.get(id);
}
});
...
```

NavController supports it:
this.navCtrl.navigateForward([`/users/${user.id}`], { state: { user } });

**Other information:**

**Ionic info:**

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。