Reputation: 370
I need to identify when an anchor is changed and so call a function
Where I set the fragment:
changeFragment(id) {
this.router.navigate([], { fragment: id });
}
Any help is welcome, thanks
Upvotes: 5
Views: 2195
Reputation: 27293
Inject ActivatedRoute service in construtor, Then use fragement method in Activatedroute to listen fragement changes
Try this:
this.route.fragment.subscribe( fragment =>{
console.log(fragment);
})
Upvotes: 7