Consider this URL:
http://localhost:4200/items
I use Location.go() to update the URL when an element is opened (expanded) in my GUI:
http://localhost:4200/items;openedId=123
When I hit the back button, the URL is changed back to http://localhost:4200/items, but my subscription on ActivatedRoute.paramMap is not triggered. (and therefore my item is stays opened)
Oddly enough, it is triggered when I open two elements consecutively, and then hit back two times:
Open main page -> http://localhost:4200/items
Open item 123 -> http://localhost:4200/items;openedId=123
Open item 456 -> http://localhost:4200/items;openedId=456
Back to http://localhost:4200/items;openedId=123 -> ActivatedRoute.paramMap triggered
Back to http://localhost:4200/items -> ActivatedRoute.paramMap triggered (!)
Why isnt't it triggered the first time? Why do I need to have two history entries before it works? I am confused.
Update: This is how I listen for changes in the paramMap:
public ngOnInit() {
this.subscriptions.add(this.activatedRoute.paramMap.subscribe(paramMap => {
this.handleNavigation(paramMap);
}));
}
from After a Location.go(), History.back() does not trigger ActivatedRoute.paramMap
No comments:
Post a Comment