【发布时间】:2016-11-11 01:38:04
【问题描述】:
我想要当前路线的未解析版本
即:dashboard/:id
我不希望 id 部分显示为数字。
这就是我在做的事情
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"@ngrx/core": "^1.2.0",
"@ngrx/store": "^2.2.1",
"core-js": "^2.4.1",
"ng2-breadcrumb": "^0.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
尝试浏览 Router 和 ActivatedRoute 并找不到它..
constructor(
private activatedRoute: ActivatedRoute,
private router: Router
) {
console.log(this.activatedRoute.routeConfig.path)
}
Error in ./AppComponent class AppComponent - inline template:54:2 caused by: Cannot read property 'path' of null
【问题讨论】:
-
你能上传你的路线配置吗?您在哪个组件中遇到了该错误? @hamobi