I'm working with Angular 6.2 & Angular Material.
I have a page with mat tabs (3 tabs).
It is possible to redirect in this page but with the 3rd tab active? From clicking a link in the navbar.
It looks like not possible, there isn't any solution for this on websites.
解决方案
I found a good solution:
I use queryParams
Link
Then I set my tab active if there is tab & it's value = notifications:
[active]="tab && tab === 'notifications'"
In the controller I set tab (this.tab) if there is queryparams and I remove it so I never see
?tab=notifications
in my URL.
ngOnInit() {
this.activatedRoute.queryParams.subscribe((params) => {
if (params.tab) {
this.tab = params.tab;
this.route.navigate([], {
queryParams: {
tab: null,
},
queryParamsHandling: 'merge',
});
}
});
}