Lifecycle Hooks routerlink vs Browser URL?
Hi, I don't completely understand the Lifecycle Hooks via routerlink vs Browser URL?
For example, visiting localhost:4200/places/3983j3hhb21kj4 from clicking an item on a list on localhost:4200/places/ via routerLink
Versus
Typing directly localhost:4200/places/3983j3hhb21kj4 into my browser.
I'm seeing different behaviors when using a geocoder api. Works fine for the 2nd in the browser, just not on routerLinks.
Angular 7.2
Posted Apr 17, 2019, 1:04 AM UTC
It could be because the component at the URL /places and /places/:id are the same. If this is the case, it should be noted that ngOnInit doesn't run each time you change the URL. You have to subscribe to the route changes in ngOnInit to get the desired behaviour.