Last active
August 7, 2022 18:27
-
-
Save Burgov/c83d88075792bac7832d1d063bb0bb83 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
@Component({ | |
selector: 'parent-component', | |
template: '<child-component [myInput]="myData" (myOutput)="handleEvent($event)"></child-component>' | |
}) | |
export class ParentComponent { | |
protected myData = 'my data'; | |
handleEvent(counter: number) { | |
alert(counter); | |
} | |
} | |
@Component({ | |
selector: 'child-component', | |
template: '<div (click)="emitCounter()">{{ myData }}</div>' | |
}) | |
export class ChildComponent { | |
@Input() myInput!: string; | |
@Output() myOutput = new EventEmitter<number>(); | |
private counter = 0; | |
emitCounter() { | |
this.myOutput.emit(++counter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment