why ActivatedRoute in @angular\router params is observable?

后端 未结 2 990
说谎
说谎 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:07

    The matrix parameters scoped to this route. The observable will emit a new value when the set of the parameters changes.

    The reason that the params property on ActivatedRoute is an Observable is that the router may not recreate the component when navigating to the same component. In this case the parameter may change without the component being recreated.

提交回复
热议问题