Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
two-way-databinding Angular
import { Component, Input, Output, EventEmitter } from '@angular/core';
selector: 'my-child',
template: `<p>V1 Childvalue Name: "{{name}}"<br/><input [(ngModel)]="name" (keyup)="onNameChanged()"> <br/><br/>
<p>V2 Childvalue Age: "{{age}}"<br/><input [(ngModel)]="age" (keyup)="onAgeChanged()"> <br/></p>`
export class ChildComponent {
@Input() name : string;
@Output() nameChange = new EventEmitter<string>();
@Input() age : string;
@Output() ageChanged = new EventEmitter<string>();
public onNameChanged() {
public onAgeChanged() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment