Skip to content

Instantly share code, notes, and snippets.

View wKoza's full-sized avatar
🌏
A new opportunity ? hmmm why not

William Koza wKoza

🌏
A new opportunity ? hmmm why not
  • Self-employment
  • France
View GitHub Profile
import {Directive, Renderer2, ElementRef, HostListener, Input} from '@angular/core';
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective {
@Input('appHighlight') highlightColor: string;
private _defaultColor = 'red';
<div [appHighlight]="'yellow'">Texte en highlight</div>
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 {
import {Component, Input} from '@angular/core';
@Component({
selector: 'app-comp1',
template: `
{{monAdresse.street}}
`
})
export class Comp1Component {
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>
`
import {Component, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-comp2',
template: `
<button (click)="decrement()" > - </button>
<button (click)="increment()"> + </button>
`
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>
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>
<input [(ngModel)]="prenom">
<input
[ngModel]="currentHero.firstName"
(ngModelChange)="currentHero.firstName=$event">