Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角激活路线_Angular_Angular Routing - Fatal编程技术网

Angular 角激活路线

Angular 角激活路线,angular,angular-routing,Angular,Angular Routing,我有这个链接: 最后一个例子是: console.logthis.ar.root.children[0]。children[0]。snapshot.params['other'] //另一种 好的,我有我的结果,但我不认为这是最好的选择,对吗 p、 “这个陌生人” 您可以通过多种方式获取路线参数 当组件首次加载时。 订阅可观测数据并在参数更改时接收更新。 这将在组件首次加载时为您提供参数。如果路由器参数更改,则不会收到更新的值 另一个选项是订阅可观察的参数 this.ar.params.sub

我有这个链接:

最后一个例子是:

console.logthis.ar.root.children[0]。children[0]。snapshot.params['other'] //另一种

好的,我有我的结果,但我不认为这是最好的选择,对吗


p、 “这个陌生人”

您可以通过多种方式获取路线参数

当组件首次加载时。 订阅可观测数据并在参数更改时接收更新。 这将在组件首次加载时为您提供参数。如果路由器参数更改,则不会收到更新的值

另一个选项是订阅可观察的参数

this.ar.params.subscribe(params => {
  this.anotherId = params.anotherId;
});
如果路由参数发生更改,将通知上述人员更改的参数


谢谢,我知道observable和“刷新”,但我正在寻找:this.ac.snapshot.params.anotherId;再次感谢
this.ar.params.subscribe(params => {
  this.anotherId = params.anotherId;
});