Skip to content

Instantly share code, notes, and snippets.

@wKoza
Last active July 25, 2017 14:01
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/223b2d83dc34d7e19b9fc42d3f32a52f to your computer and use it in GitHub Desktop.
Save wKoza/223b2d83dc34d7e19b9fc42d3f32a52f to your computer and use it in GitHub Desktop.
import {Component, Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'ma-taille',
template: `
<div>
<button (click)="dec()" title="plus petit">-</button>
<button (click)="inc()" title="plus grand">+</button>
<label [style.font-size.px]="taille">FontSize: {{taille}}px</label>
</div>
`
})
export class maTailleComponent {
@Input() taille: number;
@Output() tailleChange = new EventEmitter<number>();
dec() { this.resize(-1); }
inc() { this.resize(+1); }
resize(delta: number) {
this.taille = +this.taille + delta;
this.tailleChange.emit(this.taille);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment