Questions tagged «angular2-router»

5
我是否必须取消订阅ActivatedRoute(例如params)可观察对象?
我发现了许多示例,其中ActivatedRouteObservable喜欢params或url已订阅但未取消订阅。 constructor(private route: ActivatedRoute) {} ngOnInit() { this.route.params // (+) converts string 'id' to a number .switchMap((params: Params) => this.service.getHero(+params['id'])) .subscribe((hero: Hero) => this.hero = hero); } 路径对象和订阅是否会自动销毁,并在每次创建组件时都重新创建? 我是否需要取消订阅那些邮件Observable? 如果没有,您能否解释一下中的ActivatedRoute对象树的情况Router。routerState?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.