Can someone please explain where I need to declare activeIndex variable and how to properly use it?
Here is my code in the HTML file:
<p-tabMenu [model]="tabMenuItems"></p-tabMenu>
And here is the TypeScript file:
tabMenuItems: MenuItem[];
private stateId: number;
private id: number;
...
ngOnInit() {
this.tabMenuItems = [
{label: 'Bar1', icon: 'ui-icon-insert-chart',
command: (event: any) => {
this.router.navigate(['/#',
this.id],{ queryParams: {'stateId': this.stateId} }); }
},
{label: 'Bar2', icon: 'ui-icon-date-range',
command: (event: any) => {
this.router.navigate(['/#', this.id],{ queryParams: {'stateId': this.stateId} }); }
},
{label: 'Bar3', icon: 'ui-icon-book',
command: (event: any) => {
this.router.navigate(['/#', this.id],
{ queryParams: {'stateId': this.stateId} }); }
},
{label: 'Bar4', icon: 'ui-icon-help-outline',
command: (event: any) => {
this.router.navigate(['/#', this.id],
{ queryParams: {'stateId': this.stateId} }); }
},
{label: 'Bar5', icon: 'ui-icon-public',
command: (event: any) => {
this.router.navigate(['/#', this.id],
{ queryParams: {'stateId': this.stateId} }); }
}
];
How can I ensure that each menu item activates the corresponding tab based on the activeIndex value?