You need to sign in to do that
Don't have an account?
Debasish Paul 6
How to Navigate between Lightning Components?
How to navigate between Lightning components and pass value between them? Please explain with example.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Let’s take a scenario there are two components i.e Component1 and Component2. Component1 accepts two user input values and we need to add these values and display the result in Component2. So, how will the component1 pass on the result to component2 ? We have to use a lightning event in this case which will allow component1 to fire the event, and can be caught by the event handlers of component2.
Lightning Event :- First create a event named "Result.evt". Since, component1 will have a value to be passed on to component2, the event should also need to have an attribute associated with it. Component:-
Component1.cmp which would accept two input values from the user and sum it.
Look at the above component, you will see that this component has registered the event “Result” using the <aura:registerEvent> tag. This is a declaration that the component states to notify that component will fire the “Result” event at some point of time.
Now create the controller for Component1.cmp
Component1Controller.js In the above controller of Component1, we are capturing the user inputs, converting it to integer data type, adding the two values and again converting it back to String data type. The final result is then passed to the “Result” event and fired.
Now, we need to define the Component2, which will display the result.
Component2.cmp In component2 <aura:handler> tag to register that it handles the application event.
When the event is fired, the handleApplicationEvent action in the client-side controller of the handler component is invoked.
Now create the controller for Component2.cmp
Component2Controller.js The controller retrieves the data from the Event named "Result" and set the retrive data in the component2 attribute name "res".
Now create a Lightning Application named "MyApp" to access these component in salesforce:-
Thanks,
Piyush Kumar
If this solution hepls to solve your query then please mark is solve that will help outher to get this solutions.
Thanks.