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 {Directive, Renderer2, ElementRef, HostListener, Input} from '@angular/core'; | |
@Directive({ | |
selector: '[appHighlight]' | |
}) | |
export class HighlightDirective { | |
@Input('appHighlight') highlightColor: string; | |
private _defaultColor = 'red'; |
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
<div [appHighlight]="'yellow'">Texte en highlight</div> |
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> | |
` | |
}) | |
export class AppComponent { |
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, Input} from '@angular/core'; | |
@Component({ | |
selector: 'app-comp1', | |
template: ` | |
{{monAdresse.street}} | |
` | |
}) | |
export class Comp1Component { |
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 personne</button> | |
` |
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, Output, EventEmitter} from '@angular/core'; | |
@Component({ | |
selector: 'app-comp2', | |
template: ` | |
<button (click)="decrement()" > - </button> | |
<button (click)="increment()"> + </button> | |
` |
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> |
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> |
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
<input [(ngModel)]="prenom"> |
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
<input | |
[ngModel]="currentHero.firstName" | |
(ngModelChange)="currentHero.firstName=$event"> |