1

This code Navigate to another component perfectly but i don't understand how to get this passed attribute value in component2

NavigateToComponent2: function(component, event, helper) {
    var evt = $A.get("e.force:navigateToComponent");
        evt.setParams({
                componentDef: "Component2",
                componentAttributes: {
                myAttribute: component.get("v.id")
            }
        });
    evt.fire();    
}
1

@Pankaj I forgot mention the second step in my previous post,

  1. you should define the attribute (that you are passing along with the event) in the target component i.e. your component2 should have 'accountid' attribute defined in it

    <aura:component implements="force:appHostable">
     <aura:attribute name="accountid" type="String" />
     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
       Hello
    </aura:component>
    
  2. also, along with the above change in the controller of your target component you will be able to access it in following manner(note: not from the event but from the component)

    doInit : function(component, event, helper) {
            alert(component.get("v.accountid")) ;
        },
    

Being said that, let me clarify that it is not recommended to use this event as, it is not yet documented in the developer guide and could be subject to any changes in the future releases with out any notice

Do confirm if the above approach worked for you.

1
  • 1
    @Pankaj did you try this approach – Gopal Rao Jun 21 '16 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.