Angular2路由.请求的路径在索引1处包含未定义的段 [英] Angular2 Routing. The requested path contains undefined segment at index 1

查看:132
本文介绍了Angular2路由.请求的路径在索引1处包含未定义的段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Angular 2中遇到路由问题. 我将router.navigate从一个动作调用到一个数据表中.罕见的是,有时当我单击调用该行的按钮时,它工作正常,而有时却没有.

I have a issue with routing in Angular 2. I call router.navigate from an action into a datatable. The rare is that sometimes when i click the button that calls this line its works fine and sometimes it doesnt.

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

显示检查器元素的错误是:

The error that shows the inspector element is:

The requested path contains undefined segment at index 1

我正在使用Angular2,DataTables和Webpack

Im using Angular2, DataTables, and Webpack

推荐答案

navigate中传递的id可能是undefinednull.请控制台输入并修复ID,然后在Navigation中传递.我有同样的问题,并已解决.

Probably your id that pass into in navigate is undefined or null.console your id and fix and then pass into in navigate .i had same issue and fixed it.

这篇关于Angular2路由.请求的路径在索引1处包含未定义的段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆