我不知道在什么情况下应该取消订阅 route.params
observable。
- Angular 文档说我们不需要取消订阅。
那么我应该取消订阅的用例是什么?
最佳答案
据此answer ,除非是动态组件或子组件,否则不应订阅:
Unsubscribe from the ActivatedRoute observables like route.params if they are subscribed inside a nested (Added inside tpl with the component selector) or dynamic component as they may be subscribed many times as long as the parent/host component exists. No need to unsubscribe from them in other scenarios as mentioned in the quote above from Routing & Navigation docs.
关于angular - 何时取消订阅 `route.params` observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51821986/