Created
October 22, 2016 14:55
-
-
Save wKoza/9093f090814d3b0dbf6f18f701d00ce2 to your computer and use it in GitHub Desktop.
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} 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