Dhe*_*wal 5 angular-routing angular
嗨,所以我已经用这样的 id 声明了我的路线,{path: 'spreadsheet/:id', component: ContactParent}所以在这里我可以id通过使用ActivatedRoute但我如何获得spreadsheet,如果我这样做this.router.url会给我spreadsheet/20但我只需要spreadsheet
尝试这个...
constructor( private route: ActivatedRoute ) {
console.log(route.pathFromRoot[1].snapshot.url[0].path);
}
Run Code Online (Sandbox Code Playgroud)
例如,如果您访问http://localhost:4200/spreadsheet/3,上面的代码将记录“spreadsheet”
| 归档时间: |
|
| 查看次数: |
8301 次 |
| 最近记录: |