Skip to content

Instantly share code, notes, and snippets.

@picheli20
Created October 31, 2018 15:34
Show Gist options
  • Save picheli20/61bb1eb074a7383d9b2d890aa24731f5 to your computer and use it in GitHub Desktop.
Save picheli20/61bb1eb074a7383d9b2d890aa24731f5 to your computer and use it in GitHub Desktop.
Library with Angular 6+: The ultimate guide - Counter component
<button (click)="increase()" class="counter-button"> {{ text }} {{ counter }} </button>
.counter-button {
font-size: 1.3rem;
border: 0;
border-radius: 5px;
padding: 10px;
min-width: 100px;
}
import { Component, Input } from '@angular/core';
@Component({
selector: 'fb-counter',
templateUrl: './counter.component.html',
styleUrls: [ './counter.component.scss' ]
})
export class CounterComponent {
@Input() text = 'Default';
counter = 0;
increase(amount = 1) {
this.counter += amount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment