[SalesForce] Use event to pass attribute from One component to Other

I have home page which has one button to create account. On click of save I want to hide my Home page component and open new component.
My Account creation component is separate component which I have included on my home page. I am using component to show hide home page but unable to get the boolean value on home page from Account creation page.

My code is:

HomePageComponent:

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:handler event="c:BP_NewAccountCreationEvent" action="{!c.getPopUpId}"/>
    <aura:attribute name="ShowNextPage" type="Boolean" default="true"/>
        {!v.body}
    <aura:if isTrue="{!v.ShowNextPage}"

AccountcreationJS

({
    myAction : function(component, event, helper) {

    },
    saveAccount : function(component, event, helper) {
        console.log('IN SaveAccount')
        var action = component.get("c.createAccount");
        action.setParams({"newAcc" : component.get("v.newAccount")});
        action.setCallback(this,function(a){
            if (a.getState() === "SUCCESS") {
                component.set("v.ShowNextPage", "false");
                $A.createComponent(
                    "c:SampleComponent",
                    {

                    },
                    function(newCmp){
                        if (component.isValid()) {
                        component.set("v.body", newCmp);
                        }
                    }

                );

            } else if (a.getState() === "ERROR") {
                $A.log("Errors", a.getError());
                console.log('****Error****');
            }

        });
        $A.enqueueAction(action);

I need ShowNextpage value from this controller to Home page component
.

Best Answer

In controller you setting a boolean value as String

component.set("v.ShowNextPage", "false");

You must set a Boolean value as

component.set("v.ShowNextPage", false);
Related Topic