Skip to content

Instantly share code, notes, and snippets.

@DonkeyKongJr
Created August 23, 2018 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DonkeyKongJr/72b1458921db4a8073d18574ab0f1ac1 to your computer and use it in GitHub Desktop.
Save DonkeyKongJr/72b1458921db4a8073d18574ab0f1ac1 to your computer and use it in GitHub Desktop.
Angular Property Binding - Child Component
<p>Parent Input is: {{parentInput}} </p>
<label >Child Component Input: </label>
<input type="text" [ngModel]="childTextValue" (ngModelChange)="updateOutput($event)">
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