MenuModel API

    TabMenu uses the common menumodel api to define its items, visit for details.

    1. <p-tabMenu [model]="items"></p-tabMenu>
    2.  

    ActiveItem

    By default item that matches the active route is highlighted, alternatively activeItem property can be used choose the initial active item.

    1. <p-tabMenu [model]="items" [activeItem]="items[0]"></p-tabMenu>
    2.  

    Menuitem content supports templating via the "item" template which gets the menuitem instance and the index.

    1. <p-tabMenu [model]="items">
    2. <ng-template pTemplate="item" let-item let-i="index">
    3. </ng-template>
    4. </p-tabMenu>
    5.  

    Properties

    NameElement
    ui-tabmenuContainer element.
    ui-tabmenu-navList element of headers.
    ui-tabmenuitemMenuitem element.
    ui-menuitem-linkLink inside a menuitem.
    ui-menuitem-textLabel of a menuitem.
    ui-menuitem-iconIcon of a menuitem.

    Dependencies

    None.

    Source

    View on GitHub

    1. export class TabMenuDemo {
    2. items1: MenuItem[];
    3. activeItem: MenuItem;
    4. ngOnInit() {
    5. this.items1 = [
    6. {label: 'Stats', icon: 'fa fa-fw fa-bar-chart'},
    7. {label: 'Calendar', icon: 'fa fa-fw fa-calendar'},
    8. {label: 'Documentation', icon: 'fa fa-fw fa-book'},
    9. {label: 'Support', icon: 'fa fa-fw fa-support'},
    10. ];
    11. this.items2 = [
    12. {label: 'Stats', icon: 'fa fa-fw fa-bar-chart'},
    13. {label: 'Documentation', icon: 'fa fa-fw fa-book'},
    14. {label: 'Support', icon: 'fa fa-fw fa-support'},
    15. {label: 'Social', icon: 'fa fa-fw fa-twitter'}
    16. ];
    17. this.activeItem = this.items2[0];
    18. }
    19. closeItem(event, index) {
    20. this.items2 = this.items2.filter((item, i) => i !== index);
    21. event.preventDefault();
    22. }
    23.