Created
August 23, 2018 12:31
-
-
Save DonkeyKongJr/72b1458921db4a8073d18574ab0f1ac1 to your computer and use it in GitHub Desktop.
Angular Property Binding - Child Component
This file contains 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
<p>Parent Input is: {{parentInput}} </p> | |
<label >Child Component Input: </label> | |
<input type="text" [ngModel]="childTextValue" (ngModelChange)="updateOutput($event)"> |
This file contains 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 { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | |
@Component({ | |
selector: 'app-child', | |
templateUrl: './child.component.html', | |
styleUrls: ['./child.component.css'] | |
}) | |
export class ChildComponent implements OnInit { | |
@Input() parentInput: string; | |
@Output() childOutput = new EventEmitter<string>(); | |
childTextValue = ''; | |
constructor() { } | |
ngOnInit() { | |
} | |
updateOutput(value) { | |
this.childOutput.emit(value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment