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

查看:30
本文介绍了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 中传入的 idundefinednull.console 你的 id 并修复,然后传入导航.我有同样的问题并修复它.

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天全站免登陆