1

Events are used to Communicate between components. I'm unable to understand why I have to use events when I can pass parameters between components as attributes?

1 Answer 1

5

When two components can "see" each other, you can pass an attribute as you mention or call a method:

Use <aura:method> to define a method as part of a component's API. This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event. Using simplifies the code needed for a parent component to call a method on a child component that it contains.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_tag_method.htm?search_text=method

Events are good for loose coupling. When two components can't see each other, then events are better than doing a search by some kind of ID and then using an attribute or a method.

You must log in to answer this question.

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