【发布时间】:2017-12-22 14:15:19
【问题描述】:
我在angular 5 中实现了一个组件,它创建了我的foo 对象,它工作正常,但之后我想编辑它,所以我将编辑路径指向同一个组件:
const routes: Routes = [
...
{ path: 'foo/new', component: NewFooComponent },
{ path: 'foo/edit/:id', component: NewFooComponent },
...
];
我的问题是如何知道我的NewFooComponent.ts 是在foo/new 路径中还是在foo/edit/:id 中?
这也是最好的方法吗?
【问题讨论】:
-
你不能测试一下你有没有
id吗? -
您可以尝试使用this answer中建议的方法获取
id。
标签: angular