You need to sign in to do that
Don't have an account?
golu
passing value from one component to another
Hi,
I am trying to pass the value from one component to another with attributes but it is not working . Can anyone please help?
I want to send the value from lightningLookupComponent to sendSMS_report component. I want to pass the value of "selItem" to sendSMS_report controller.
Below is the code for lightningLookupComponent:
Code for sendSMS_report controller. I want to pass the values in one of the setPrams function.
I am trying to pass the value from one component to another with attributes but it is not working . Can anyone please help?
I want to send the value from lightningLookupComponent to sendSMS_report component. I want to pass the value of "selItem" to sendSMS_report controller.
Below is the code for lightningLookupComponent:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"> <aura:attribute Name="selItem" type="object" access="public" /> <aura:attribute Name="selItem1" type="object" access="public" /> <aura:attribute Name="selItem2" type="object" access="public" /> <aura:attribute Name="selItem3" type="object" access="public" /> <div class="slds"> <div class="slds-grid slds-wrap"> <div class="slds-size_1-of-1 slds-small-size_1-of-1 slds-medium-size_1-of-2 slds-large-size_1-of-4 "> <c:lightningLookup objectName="Report" field_API_text="Name" field_API_val="Id" limit="4" field_API_search="Name" lookupIcon="standard:report" selItem="{!v.selItem}" placeholder="Enter space after text to search report" /> <aura:if isTrue="{! not(empty(v.selItem)) }"> <br /> This is Parent Lightning component <br /> Item Selected : <br /> ID - {#v.selItem.val} <br /> Text - {#v.selItem.text}<br /> Object - {#v.selItem.objName}<br /> <c:sendSMS_Report/> </aura:if> </div> </div> </div> </aura:component>
Code for sendSMS_report controller. I want to pass the values in one of the setPrams function.
({ sendNowOrLater : function(component, event, helper, caller){ $A.util.toggleClass(component.find("mySpinner"),"slds-show"); var action; if(caller == 'sendReportSMSNow'){ action = component.get("c.sendSMS_Report"); action.setParams({ message : component.get("v.selectedTemplateBody"), recordId : component.get("v.recordId") }); }else{ action = component.get("c.sendSMS_Report"); action.setParams({ scheduleDateTime : component.get("v.scheduleDateTime"), message : component.get("v.selectedTemplateBody"), recordId : component.get("v.recordId") }); } console.log(action); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { $A.util.toggleClass(component.find("mySpinner"),"slds-hide"); var toastEvent = $A.get("e.force:showToast"); // /**/ toastEvent.setParams({ title: "Success!", message: "The record has been created successfully ." }); toastEvent.fire(); var modal = component.find("Modal"); $A.util.addClass(modal, 'hideDiv'); var dismissActionPanel = $A.get("e.force:closeQuickAction"); dismissActionPanel.fire(); }else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { var dismissActionPanel = $A.get("e.force:closeQuickAction"); dismissActionPanel.fire(); var toastEvent = $A.get("e.force:showToast"); // // toastEvent.setParams({ title: "Failed", message: "The record was not saved" }); toastEvent.fire(); } } } }); $A.enqueueAction(action); } })
- You can use the events
- you can use the lightning:isUrlAddressable
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentationhttp://bobbuzzard.blogspot.com/2018/05/lightning-component-navigation-in.html
https://www.sfdcstuff.com/2018/09/lightningisurladdressable-interface-way.html