Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Regarding Navbar in igniteui angular
posted

Hi,

My question is regarding the navbar. The links on navbar to be changed based on roles(manufacturer, distributor,admin) i.e. based on the login role the navbar should be displayed.

Thanks in advance.

Parents Reply
  • 6365
    Offline posted in reply to Dinesh Reddy

    Hello Dinesh,

    The igx-navbar will successfully display whatever content has been presented to it, so you should be able to include a dropdown as well.

    You can use our Drop Down, Combo or even the native Select element to place it in the navbar. In addition, the isAdmin property of the underlying currentUser object can be used in order to display the element conditionally.

    For example:

    <igx-navbar #navbar actionButtonIcon="menu" [title]="currentUser.title">
    ...
    <!-- =========== IgxCombo =========== -->
    <igx-combo *ngIf="currentUser.isAdmin" class="combo" [data]="localData" height="30px">
    </igx-combo>
    
    <!-- =========== IgxDropdown =========== -->
    <div *ngIf="currentUser.isAdmin" >
    <button igxButton="raised" (click)="toggleDropDown($event)">Options</button>
    <igx-drop-down #dropdown1 class="dropdown">
    <igx-drop-down-item [igxDropDownItemNavigation]="dropdown1" *ngFor="let val of localData">
    {{ val }}
    </igx-drop-down-item>
    </igx-drop-down>
    </div>
    
    <!-- =========== Native Dropdown =========== -->
    <select *ngIf="currentUser.isAdmin" >
    <option>Option A</option>
    <option>Option B</option>
    <option>Option C</option>
    </select>
    ...
    </igx-navbar>

    Please note that in order for the default overlay element of both the IgxDropDown and the IgxCombo to be displayed on top of the navbar, we will currently have to include a global level style for the overlay:

    styles.css:

    .igx-overlay {
    position: relative;
    z-index: 24;
    }

    The IgxIcon material design icons you have referred to are merely an example for what kind of content can be placed in the navbar. They do not have a predefined specific functionality (they are just icons) and you can use them to implement logic of your own.

    I have attached a sample application that demonstrates the code-snippet approach from above.
    If you have any questions, please let me know.

    5756.navbar-modified.zip

Children
No Data