2016-11-11 56 views
-1

的無法解析的版本,我想我現在的路線角2 - 我怎樣才能讓我的電流路徑

即未解析版本: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" 
    }, 

試圖尋找通過RouterActivatedRoute並不能找到它..

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

+0

你能上傳你的路由配置?在哪個組件中你有這個錯誤? @hamobi – Michael

回答

0

ActivatedRoute你可以訪問Route,然後用path值來獲取未解析的路由。

守則Plunker

+0

我得到一個錯誤..看上面。我的路由配置爲空 – hamobi