How to re-render a component manually Angular 5

后端 未结 5 1321
耶瑟儿~
耶瑟儿~ 2020-12-31 01:38

Is there a way I can re render a component manually, say when a user clicks a button??

I\'ve seen similar posts but none of these worked for me for example here

5条回答
  •  长发绾君心
    2020-12-31 02:13

    You could trick the router into rendering a fresh copy of current component by temporarily overriding route reuse strategy.. found in some other SO answer :)
    in ngOnInit:

    this.router.routeReuseStrategy.shouldReuseRoute = () => false;
    

提交回复
热议问题