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");
                componentDef: "Component2",
                componentAttributes: {
                myAttribute: component.get("v.id")

1 Answer 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}"/>
  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
    @Pankaj did you try this approach
    – Gopal Rao
    Jun 21, 2016 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .