Skip to content

Instantly share code, notes, and snippets.

@frontendloader
Created February 1, 2016 21:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frontendloader/34bfebf06c4fa3b61036 to your computer and use it in GitHub Desktop.
Save frontendloader/34bfebf06c4fa3b61036 to your computer and use it in GitHub Desktop.
Lightning navigation example
<aura:component implements="c:view">
<div>Using view 'bar': {!v.message}</div>
<ui:button label="Navigate to bar" press="{!c.navTofoo}"/>
</aura:component>
({
navToFoo : function(component, event, helper) {
$A.get("e.c:navigateToView").setParams({view: "foo"}).fire();
}
})
<aura:component implements="c:view">
<div>Using view 'foo': {!v.message}</div>
<ui:button label="Navigate to bar" press="{!c.navToBar}"/>
</aura:component>
({
navToBar : function(component, event, helper) {
$A.get("e.c:navigateToView").setParams({view: "bar"}).fire();
}
})
<aura:application access="GLOBAL">
<aura:attribute name="message" type="String" default="Hello"/>
<aura:handler event="c:navigateToView" action="{!c.navigateToView}"/>
The message: <ui:inputText value="{!v.message}" updateOn="keyup"/>
<div aura:id="content">
<c:foo message="{!v.message}"/>
</div>
<!-- Workaround for aura:dependency not being access="GLOBAL" to keep newCmpAsync() client side -->
<aura:if isTrue="false"><c:bar/></aura:if>
</aura:application>
<aura:event type="APPLICATION" description="Navigate to the specified view">
<aura:attribute name="view" type="String" required="true"/>
</aura:event>
<aura:interface description="view interface">
<aura:registerEvent name="navigateEvent" type="c:navigateToView"/>
<aura:attribute name="message" type="String"/>
</aura:interface>
@msreekm
Copy link

msreekm commented Nov 20, 2016

can you post the navcontainer controller code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment