angular8-countdown-timer
v1.0.0
Published
This library was created because no simple countdown timer was available that would work with Angular's AOT compiler.
Downloads
40
Readme
angular8-countdown-timer
This library was created because no simple countdown timer was available that would work with Angular's AOT compiler.
Installation
To install this library, run:
npm install angular8-countdown-timer --save
Use within your module
Add the following lines to your angular module:
import {NgModule} from '@angular/core';
// Import the Countdown timer module
import {AngularCountdowntimerModule} from 'angular-countdowntimer';
@NgModule({
imports: [
AngularCountdowntimerModule
]
})
export class YourModule {
}
Usage within your component:
import { Component } from '@angular/core';
@Component({
selector: 'app-your',
templateUrl: './your.component.html',
styleUrls: [ './your.component.css' ]
})
export class YourComponent {
someDate: Date;
ngOnInit() {
// set a date for 14 minutes and 12 seconds from now
this.someDate = new Date( Date.now() + (14 * 60 + 12) * 1000 );
}
myTriggerFunction() {
console.log('triggered!');
}
}
Usage within your template:
<h1>This is a title</h1>
<p>
Without always showing hours:
<countdown-timer [endDate]="someDate" (zeroTrigger)="myTriggerFunction()"></countdown-timer>
</p>
<p>
With always showing hours:
<countdown-timer [endDate]="someDate" [alwaysShowHours]="true"></countdown-timer>
</p>