ionic-team / ionic-team/ionic-framework
bug: missing state property on routerLink
- 主要语言
- TypeScript
- 星标
- 52.7k
- 派生
- 13.3k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 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:**
贡献指南
调研方向
Start with the routerLink handling for ion-item and compare it with the working anchor example in page.html; the issue links Angular's RouterLink documentation and shows the childPage.ts navigation-state lookup. Reproduce the case with [state] on ion-item, then verify that the user state is available through getCurrentNavigation().extras.state as it is for the anchor and NavController examples.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100