Answers for "countdown timer angular"

0

angular countdown timer

// Iinstall the timer package from NPM
$ npm install angular-countdown-timer --save

// Import the countdown timer module
import { NgModule } from '@angular/core';
import { CountdownTimerModule } from 'angular-countdown-timer';
 
@NgModule({
  imports: [
    CountdownTimerModule.forRoot()
  ]
})
export class YourModule { }

// Your component TS file
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');
  }
  
}

// Use the timer in your component html 
<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>
Posted by: Guest on April-16-2020
0

countdown timer angular

//Install npm package:
$ npm install ngx-countdown --save

//Import in ngModule:
...
import { CountdownModule } from 'ngx-countdown';
...
@NgModule({
  ...
  imports: [
    ...
    CountdownModule
  ],
  ...
)}
          
//Use in the component.html
<countdown [config]="{ leftTime: 100, format: 'm:s' }"></countdown>
Posted by: Guest on August-11-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language