Created
March 3, 2017 15:19
-
-
Save Sunil02kumar/faffe86276315b2d90615857aaf3d844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:event type="COMPONENT" description="Event template" > | |
<aura:attribute name="msg" type="String" access="GLOBAL"/> | |
</aura:event> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component > | |
<aura:attribute name="msgFromNotifier" type="String"/> | |
<!-- give same name as that of notifier registerEvent name attribute --> | |
<aura:handler name="newCarAccident" event="c:carAccident" action="{!c.handleNotification}"/> | |
<!-- Handler should contains notifier component--> | |
<c:carAccidentNotifier /> | |
<div>message from Notifier : <b>{!v.msgFromNotifier}</b></div> | |
</aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleNotification : function(component, event, helper){ | |
var sentMessage= event.getParam("msg"); | |
component.set("v.msgFromNotifier", sentMessage); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component > | |
<aura:registerEvent name="newCarAccident" type="c:carAccident"/> | |
<h1>Car Accident Example: Fire Event by Clicking on Button</h1> | |
<ui:button label="Accident Took Place" press="{!c.fireCarAccidentEvent }"/> | |
</aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
fireCarAccidentEvent : function(component, event, helper) { | |
var accidentEvent = component.getEvent("newCarAccident"); | |
accidentEvent.setParams({"msg":"there is car Accident. Send ambulance."}); | |
accidentEvent.fire(); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:application extends="force:slds" > | |
<c:CarAccidentHandler/> | |
</aura:application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment