Which is an example of a component event?

Which is an example of a component event?

Here’s a simple use case of using a component event to update an attribute in another component. A user clicks a button in the notifier component, ceNotifier.cmp. The client-side controller for ceNotifier.cmp sets a message in a component event and fires the event.

How to fire event in C cenotifier component?

The c:ceNotifier component uses aura:registerEvent to declare that it may fire the component event. The button in the component contains an onclick browser event that is wired to the fireComponentEvent action in the client-side controller. The action is invoked when you click the button.

How to create a component event in aura?

Note that name=”cmpEvent” in aura:registerEvent The controller retrieves the data sent in the event and uses it to update the messageFromEvent attribute in the handler component. Add the c:ceHandler component to a c:ceHandlerApp application. Navigate to the application and click the button to fire the component event.

How does a controller handle an action handler?

In the action handler, the controller gets the button that was clicked, pulls the label text out of it, and then sets the component’s message attribute to that text (2). And the message of the day is updated (3). Today is going to be a great day! Simple, right?

How does the cenotifier component fire the event?

The ceEvent.evt component event has one attribute. We’ll use this attribute to pass some data in the event when it’s fired. The c:ceNotifier component uses aura:registerEvent to declare that it may fire the component event.

Which is the handler component in Lightning aura?

The handler component, ceHandler.cmp, contains the notifier component, and handles the fired event. The client-side controller for ceHandler.cmp sets an attribute in ceHandler.cmp based on the data sent in the event. The event and components in this example use the default c namespace.