countdown 5 min angular code example
Example: angular countdown timer
$ npm install angular-countdown-timer --save
import { NgModule } from '@angular/core';
import { CountdownTimerModule } from 'angular-countdown-timer';
@NgModule({
imports: [
CountdownTimerModule.forRoot()
]
})
export class YourModule { }
import { Component } from '@angular/core';
@Component({
selector: 'app-your',
templateUrl: './your.component.html',
styleUrls: [ './your.component.css' ]
})
export class YourComponent {
date = new Date('2019-01-26T00:00:00');
triggerFunction() {
console.log('Timer Ended');
}
}
<h1>{{title}}</h1>
Timer mode:
<countdown-timer [start]="date"></countdown-timer>
Countdown:
<countdown-timer [end]="date"></countdown-timer>
Countdown with zero trigger:
<countdown-timer (zeroTrigger)="triggerFunction()" [end]="date"></countdown-timer>