Angular2 Routing. The requested path contains an undefined segment at index 1

I have a routing problem in Angular 2. I am calling router.navigate from an action in datatable. It’s rare that sometimes when I press the button that calls this line, it works fine, and sometimes it doesn’t.

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

Error displaying inspector element:

 The requested path contains undefined segment at index 1 

Im using Angular2, DataTables and Webpack

+13
angular webpack navigation routing datatables
source share
3 answers

Perhaps your id that goes into navigate is undefined or null .console your identifier and fix, and then go to navigation, th was the same question and set it.

+10
source share

The problem is with the identifier. Check the data type used and the format in which it is received.

0
source share

I use

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

and the problem is stopped.

-3
source share

All Articles