2017-04-08 178 views
8

我在Angular 2中有路由問題。 我將router.navigate從一個行爲調用到一個數據表中。罕見的是,有時當我點擊調用這條線的按鈕時,它的工作正常,有時它沒有。Angular2路由。請求的路徑包含索引1處的未定義段

this.router.navigate(['edit', id], {relativeTo: this.activatedRoute}); 

,顯示檢查元素的錯誤是:使用Angular2,DataTable和的WebPack

+0

更新 - >問題是,有時閱讀ID,有時沒有。所以問題出在Datatables上。 –

回答

-3

我使用

this.router.navigate(['\edit\'+id]... 

和問題採空

The requested path contains undefined segment at index 1 

林。

+0

這是一個更好的解決方案:https://stackoverflow.com/questions/43396673/angularjs-2-error-undefined-index1 – Tuure

1

可能你的id進入navigate未定義或null.console你的ID和修復,然後進入導航.i有同樣的問題,並修復它。