Count down
IMPORT MODULE

The countdown component depends on ngx-countdown.

Dependencies

yarn add ngx-countdown

Examples

00:00:09
Basic

The simplest usage.

expand codeexpand code
import { Component } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { CountdownEvent } from 'ngx-countdown';

@Component({
  selector: 'components-count-down-simple',
  template: `
    <div>
      <count-down #cd [target]="10" (event)="handleEvent($event)" style="font-size: 20px;"></count-down>
    </div>
    <button nz-button (click)="cd.instance.pause()">Pause</button>
    <button nz-button (click)="cd.instance.resume()">Resume</button>
  `,
})
export class ComponentsCountDownSimpleComponent {
  constructor(private msg: NzMessageService) {}

  handleEvent(e: CountdownEvent): void {
    if (e.action === 'done') {
      this.msg.success('finised');
    }
  }
}
30.0
Accuracy

The 0.1s accuracy usage.

expand codeexpand code
import { Component } from '@angular/core';
import { CountdownConfig } from 'ngx-countdown';

@Component({
  selector: 'components-count-down-accuracy',
  template: ` <count-down [config]="config"></count-down> `,
})
export class ComponentsCountDownAccuracyComponent {
  config: CountdownConfig = {
    format: `s.S`,
    leftTime: 30,
  };
}

API

count-down

PropertyDescriptionTypeDefault
[target]Target time, number means secondsnumber | Date-
[config]Config paramentsCountdownConfig-
(event)Event notificationEventEmitter<CountdownEvent>-