Angular2 : How to refresh resolver dependent components?

前端 未结 2 1266
滥情空心
滥情空心 2021-02-20 09:48

I have three components, each have their own resolver that fetch data from a different API. To do so, these components rely on an url, that is shared between them using a servic

2条回答
  •  清酒与你
    2021-02-20 10:32

    It is not currently possible to refresh routes. It will probably be possible to do that with RouteReuseStrategy in Angular 2.3.

    Resolvers are reevaluated when a route changes and can be observed from ActivatedRoute. They are not reevaluated if a route stays the same (no param is changed) and should be designed accordingly.

    Route change is asynchronous, the workaround is to chain route changes:

    this.router.navigateByUrl('blank').then(() => {
      this.router.navigateByUrl('home/(mapps:mobil//sw:simil//sf:sales)');
    })
    

提交回复
热议问题