Created
June 21, 2019 19:59
-
-
Save JitendraZaa/c87c616df3fbf1112a9523a31c50abca to your computer and use it in GitHub Desktop.
Lightning Web Component, Nested Child Components event Handling
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
div{ | |
background-color: #ddd; | |
} |
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
<template> | |
<div onclick={customClick}> | |
This is Model 3 Component , Click Me - {log} | |
</div> | |
</template> |
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
import { LightningElement, track } from 'lwc'; | |
export default class Model3 extends LightningElement { | |
@track log = ''; | |
customClick() { | |
const event = new CustomEvent('modelclick', { | |
// detail contains only primitives | |
detail: 'Event Started in Tesla Model 3' | |
}); | |
// Fire the event from model 3 | |
this.dispatchEvent(event); | |
this.log = ' - Model 3 clicked'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment