Newer Version Available
getNavigationItems() for Lightning Experience
Returns information about all the items in the item menu. This method works only in
Lightning console apps.
Arguments
None
Sample Code
This component has a button that, when pressed, returns information about the navigation items in a console app.
Component code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global">
2 <lightning:navigationItemAPI aura:id="navigationItemAPI"/>
3 <lightning:button label="Get navigation item" onclick="{!c.getNavigationItems}"/>
4</aura:component>Controller code:
1({
2 getNavigationItems : function(component, event, helper) {
3 var navigationItemAPI = component.find("navigationItemAPI");
4 navigationItemAPI.getNavigationItems().then(function(response) {
5 console.log(response);
6 })
7 .catch(function(error) {
8 console.log(error);
9 });
10 }
11})Response
This method returns a promise that, upon success, resolves to an array of navigationItemInfo objects. The promise is rejected on error.
The navigationItemInfo object contains the following fields.
| Name | Type | Description |
|---|---|---|
| label | string | The navigation item’s label, such as Account or Case. |
| developerName | string | The navigation item’s developer name that uniquely identifies the item. For example, Salesforce_Account or Your_VF_Page_Name. |
| selected | boolean | True if the tab is currently selected, false otherwise. |
| pageReference | object | The representation of the current page. The object returns information such as: page type (for example standard__objectPage or standard__navItemPage), object API name, and state information for the page. |
Here’s the structure of a navigationItemInfo
object.
1{
2 developerName : string,
3 label : string,
4 pageReference: object,
5 selected : boolean
6}