1.0.4 • Published 5 years ago

ng6-countdown v1.0.4

Weekly downloads
15
License
MIT
Repository
github
Last release
5 years ago

Ng6 Countdown

A simple countdown for angular 6 based in materialize-css.

Pre-requisites

Quickstart:

You can install run the next command.

  • npm install ng6-countdown

in app.module file.

import { BrowserModule } from  '@angular/platform-browser';
import { NgModule } from  '@angular/core';

import { CountDownModule } from  'ng6-countdown';

import { AppComponent } from  './app.component';

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

in html file.

<lib-countdown  date="October 18, 2019 00:33"></lib-countdown>

the result is: default

  • Custom card colors and bind finish date from controller. html file
<!-- Set card background color to white and set card text color to black -->
<lib-countdown
[date]="finishDate"
cardBackgroundColor="white"
cardTextColor="black">
</lib-countdown>

controller file

import { Component } from  '@angular/core';
@Component({
selector:  'app-root',
templateUrl:  './app.component.html',
styleUrls: ['./app.component.css']
})
export  class  AppComponent {
finishDate  =  'October 18, 2019 00:33';
}

the result is: npm.io

  • Custom template. html file
<!-- Show time remainig with custom template -->

<lib-countdown
[date]="finishDate"
isCustomTemplate="isCustomTemplate"
(daysChanged)="onDaysChanged($event)"
(hoursChanged)="onHoursChanged($event)"
(minutesChanged)="onMinutesChanged($event)"
(secondsChanged)="onSecondsChanged($event)">
<div  class="row">
  <div  class="col s12">
    <div  class="card">
      <div  class="card-image waves-effect waves-block waves-light">
        <p  class="number-style center-align">  <strong  class="text-bold">Days Remaining: </strong> {{days}} </p><br>
        <p  class="number-style center-align">  <strong  class="text-bold">Hours Remaining: </strong> {{hours}} </p><br>
        <p  class="number-style center-align">  <strong  class="text-bold">Minutes Remaining: </strong> {{minutes}} </p><br>
        <p  class="number-style center-align">  <strong  class="text-bold">Seconds Remaining: </strong> {{seconds}} </p><br>
      </div>
      <div  class="card-content"  [style.background]="backgroundColor">
        <span  class="card-title activator white-text text-darken-4 center-align"  [style.color]="textColor">I'm a custom card</span>
      </div>
    </div>
  </div>
</div>
</lib-countdown>

in controller file.

import { Component } from  '@angular/core';

@Component({
selector:  'app-root',
templateUrl:  './app.component.html',
styleUrls: ['./app.component.css']
})
export  class  AppComponent {
  title = 'app';
  finishDate = 'October 18, 2019 00:33';
  isCustomTemplate = true;
  days;
  hours;
  minutes;
  seconds;
  backgroundColor = 'red';
  textColor = 'black';

onDaysChanged(days) {
this.days  =  days;
}

onHoursChanged(hours) {
this.hours  =  hours;
}

onMinutesChanged(minutes) {
this.minutes  =  minutes;
}

onSecondsChanged(seconds) {
this.seconds  =  seconds;
}
}

the result is: npm.io

Documentation

Inputs

NAMETYPEDESCRIPTIONDEFAULT VALUE
datestringrepresents the finish date.none
titlestringrepresents the title in html fileThe time remaining is:
daysTextstringrepresents days title in html fileDays
hoursTextstringrepresents hours title in html fileHours
minutesTextstringrepresents minutes title in html fileMinutes
secondsTextstringrepresents seconds title in html fileSeconds
isCustomTemplatebooleanflag to indicate if use a custom templatefalse
cardBackgroundColorstringrepresents background color of cardseagreen
cardTextColorstringrepresents text color of cardwhite

Outpouts

NAMETYPEDESCRIPTIONEMIT VALUE
daysChangedEventEmitterfired an event when days value changed.number
hoursChangedEventEmitterfired an event when hours value changed.number
minutesChangedEventEmitterfired an event when minutes value changed.number
secondsChangedEventEmitterfired an event when seconds value changed.number

Supported Browsers:

  • Google Chrome
  • Firefox
  • Edge
  • Internte Explorer ( You should enable polyfills to enable IE browsers)
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago