• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, easy and performance countdown for angular

ngx-countdown

Simple, easy and performance countdown for angular

NPM version Ci

Demo

Usage

1. Install

npm install ngx-countdown --save

import CountdownModule

import { CountdownModule } from 'ngx-countdown';

@NgModule({
  imports: [ BrowserModule, CountdownModule ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule { }

2、Template

<countdown #cd [config]="config" (event)="handleEvent($event)"></countdown>

Method

Name Description
begin() Start countdown, you must manually call when demand: false
restart() Restart countdown
stop() Stop countdown, must call restart when stopped, it's different from pause, unable to recover
pause() Pause countdown, you can use resume to recover again
resume() Resume countdown

How call component methods

@ViewChild('cd', { static: false }) private countdown: CountdownComponent;
this.countdown.begin();

API

countdown

Name Type Default Summary
config CountdownConfig - Config
event EventEmitter<CountdownEvent> - Events

CountdownConfig

Name Type Default Summary
demand boolean false Start the counter on demand, must call begin() to starting
leftTime number 0 Calculate the remaining time based on the server, e.g: 10,5.5, (Unit: seconds)
stopTime number - Refers to counting down from local time to end time (Unit: Milliseconds second UNIX timestamp)
format string HH:mm:ss Formats a date value, pls refer to Accepted patterns
prettyText (text: string) => string - Beautify text, generally used to convert formatted time text into HTML
notify number[], number - Should be trigger type notify event on the x second. When values is 0 will be trigger every time
formatDate CountdownFormatFn - Default based on the implementation of formatDate in @angular/common, You can changed to other libs, e.g: date-fns
timezone string +0000 A timezone offset (such as '+0430'), or a standard UTC/GMT. When not supplied, uses the end-user's local system timezone

CountdownEvent

Name Type Summary
action start,stop,restart,pause,resume,notify,done Action of the event
status CountdownStatus Status of the countdown
left number Number of remaining milliseconds
text string Format the text

Global Config

function countdownConfigFactory(): CountdownConfig {
  return { format: `mm:ss` };
}

@NgModule({
  imports: [ CountdownModule ],
  providers: [
    { provide: CountdownGlobalConfig, useFactory: countdownConfigFactory }
  ],
})
export class AppDemoModule {}

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

More Repositories

1

ngx-weui

WeUI for angular
TypeScript
426
star
2

ngx-ueditor

Angular for Baidu UEditor
JavaScript
172
star
3

vscode-cssrem

Converts between `px` and `rem` units in VSCode
TypeScript
150
star
4

ngx-filesaver

Simple file save with FileSaver.js
TypeScript
86
star
5

ngx-notify

一个无须依赖HTML模板、极简Angular通知组件。
TypeScript
79
star
6

ngx-tinymce

Angular for tinymce
TypeScript
78
star
7

ng-tree-antd

A antd style of based on angular-tree-component.
CSS
67
star
8

angular-baidu-maps

Baidu Maps for Angular.
TypeScript
49
star
9

ngx-address

A simple address picker in angular.
TypeScript
46
star
10

nz-schema-form

ng-zorro-antd form generation based on JSON-Schema
TypeScript
40
star
11

angular-city-select

AngularJS 省份城市联动
JavaScript
38
star
12

ngx-simplemde

Angular for simplemde(Markdown Editor)
TypeScript
36
star
13

angular-web-storage

Angular decorator to save and restore of HTML5 Local&Session Storage
HTML
33
star
14

angular-practice

Learn and understand Angular
JavaScript
26
star
15

ngx-highlight-js

Angular for syntax highlighting with highlight.js
HTML
26
star
16

g2-angular

Angular for Alipay G2
TypeScript
25
star
17

ngx-bootstrap-modal

simplify the work with bootstrap modal dialogs
TypeScript
22
star
18

ngx-umeditor

Angular for Baidu UMeditor
JavaScript
21
star
19

ng-deploy-oss

Deploy Angular apps to aliyun OSS, qiniu, upyun using the Angular CLI. 🚀
TypeScript
19
star
20

angular-qq-maps

Angular 2+ QQ Maps Components
TypeScript
19
star
21

vscode-snippet-generator

Generate a snippet extensions for vscode.
TypeScript
18
star
22

ng-zorro-antd-extra

ng-zorro-antd extra episode!
CSS
16
star
23

ngx-webuploader

Angular for Baidu WebUploader
JavaScript
13
star
24

ngx-gesture-password

A smart gesture password locker for angular
TypeScript
13
star
25

zh-hans-tt-hant-vscode

VSCODE 中文简体与繁体互转,支持台湾地区惯用词汇替换
TypeScript
13
star
26

ng-code-style-boilerplate

A code style boilerplate for angular8
TypeScript
11
star
27

cipchk-vscode

cipchk-vscode for cipchk only.
11
star
28

blog-ngdemo-structure

TypeScript
9
star
29

ngx-wangeditor

wangEditor的Angular版本
JavaScript
5
star
30

ng-github-button

Unofficial GitHub buttons in Angular.
HTML
5
star
31

vscode-markdown-compact-table-formatter

Format Markdown tables in a compact way / 以紧凑的方式格式化 Markdown 表格
TypeScript
4
star
32

JWTDemo

ASP.NET Web API的JWT(Json Web Token)示例。
C#
3
star
33

ng-clipboard-antd

A wrapper directive for clipboard.js, and base on ng-zorro-antd.
TypeScript
3
star
34

ngx-dgeni-start

如何将Angular文档化?
TypeScript
3
star
35

angular.xheditor

xhEditor的AngularJS版本。
JavaScript
3
star
36

vscode-snippet-generator-tpl

vscode-snippet-generator template
2
star
37

inputmagnify

Input放大镜,像在输入手机号或身份证号码时,每四位插入一个分隔符。
JavaScript
2
star
38

ng-less-javascript-enabled-patch

Fix +Angular17 Less not supporting `javascriptEnabled`.
TypeScript
2
star
39

alain

Development tools and libraries specialized for ng-alain
1
star