Où puis-je déclarer activeIndex et comment utiliser cette variable?Comment définir l'onglet actif dans l'onglet PrimeNGMenu?
je fichier html:
<p-tabMenu [model]="tabMenuItems"></p-tabMenu>
et le fichier tapuscrit:
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} }); }
}
];
Comment définir l'onglet actif, de sorte que chaque élément de menu activer l'onglet correspondant?
ajouter [activeItem] = "activeItem" => activeItem est que vous l'objet sélectionné dans le composant – Chandru