Skip to content

Instantly share code, notes, and snippets.

@wKoza
Created October 22, 2016 14:55
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 wKoza/9093f090814d3b0dbf6f18f701d00ce2 to your computer and use it in GitHub Desktop.
Save wKoza/9093f090814d3b0dbf6f18f701d00ce2 to your computer and use it in GitHub Desktop.
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div [align]="alignement" [ngStyle]="{color:couleur}">Personne : {{person}} | Age : {{age}} | Adresse : {{address.street}}</div>
<app-comp1 [monAdresse]="address"></app-comp1>
<button (click)="modifierPersonne()">Modifier adresse</button>
<h1>Event binding - Compteur</h1>
<div><app-comp2 (counterChange)="myValueChange($event);"> </app-comp2></div><br/>
<div>Valeur récupérée : {{compteur}}</div>
<h1>Data binding 2-way</h1>
<div><input [(ngModel)]="person"/></div>
`
})
export class AppComponent {
person: string= 'John Doe';
age: number= 30;
address: any= {street: 'rue du Paradis', city: '75010 Paris'};
alignement: string = 'right';
couleur: string = 'red';
compteur: any = 'N/A';
myValueChange (event) {
this.compteur = event.value;
}
modifierPersonne () {
this.person = 'Another man';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment