why ActivatedRoute in @angular\router params is observable?

后端 未结 2 989
说谎
说谎 2021-02-05 13:29

why ActivatedRoute in @angular\\router params is observable ?

I\'m wondering why do I need to subscribe for Params ? and why params are async

2条回答
  •  情话喂你
    2021-02-05 14:11

    You can use

    route.routerState.params
    

    You can subscribe because when your application navigates to the same route with just another parameter value, the component is not recreated and you have no way of knowing when the parameters have changes.

    With subscribing to parameters you get notified, that a route action has happened where only the parameter value changed.

提交回复
热议问题