ionic-team / ionic-team/ionic-framework

bug: missing state property on routerLink

Đang mở
#19,291 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
package: angular type: bug
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

# 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:**

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.