Skip to content

Instantly share code, notes, and snippets.

@squadwuschel
Created May 15, 2017 19:41
Show Gist options
  • Save squadwuschel/420c596ae1f0caf8616b4a2191b3a0d4 to your computer and use it in GitHub Desktop.
Save squadwuschel/420c596ae1f0caf8616b4a2191b3a0d4 to your computer and use it in GitHub Desktop.
two-way-databinding Angular
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<p>V1 Parentvalue Name: "{{firstname}}"<br/><input [(ngModel)]="firstname" > <br/><br/>
V2 Parentvalue Age: "{{alter}}" <br/><input [(ngModel)]="alter"> <br/><br/>
<my-child [(name)]="firstname" [age]="alter" (ageChanged)="alter = $event"></my-child></p>`
})
export class AppComponent {
firstname = 'Angular';
alter = "18";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment