0

I am using angular 1.5 component router. I need to be able to change the title shown on the browser tab whenever there is a route change.

I have gone through the component router docs and googled it to many a websites but without any luck. The only way I can see to do it, is using vanilla JS inside each component's $onInit method.

I am looking out for an angular way of doing it and setting all the titles in one place. Please help.

Bharat Gupta
  • 2,628
  • 1
  • 19
  • 27
  • Just to mention that the angular 1.5 component router is already deprecated and wont be receiving any updates. You can stick with the previous angular router or use ui-router for now while the angular 1 team investigates back porting the angular 2.x router to 1.x. Just in case you're planning to use this in production, if so it would be a waste of time. – Dan Purdy Dec 13 '16 at 20:55
  • @Dan I agree that the component router in angular 1.5 is deprecated. Does the component router in angular 2 work differently? I guess angular 2 uses component router. – Bharat Gupta Dec 13 '16 at 22:35
  • Yes the angular 2 router is different and doesn't yet work in angular 1 though they're attempting to back port it to future angular 1.x releases. For now I would recommend sticking with ui-router in angular 1.x you can achieve almost component like routing fairly easily. – Dan Purdy Dec 13 '16 at 23:15

0 Answers0