siddii / angular-timer

re-usable/inter-operable AngularJS timer directive ⛺
http://siddii.github.io/angular-timer/
MIT License
792 stars 938 forks source link

Customise countdown visualization #317

Open Riccardo-Andreatta opened 7 years ago

Riccardo-Andreatta commented 7 years ago

Is there the option to have a custom visualisation of the count down? For example, I have something like the following

<timer countdown="10041" max-time-unit="'minute'" interval="1000">{{days}} day{{daysS}}, {{hours}} hour{{hoursS}}, {{minutes}} minute{{minutesS}}</timer>

I would like that when there are no more days left, they disappear, and also the when there are no more hours left, and when there are no more minutes the seconds are shown.

I have tried to put them in a sort of ng-if statement but this solution does not work, so maybe I am doing something wrong?

<div ng-if="w">
    <timer countdown="10041" max-time-unit="'minute'" interval="1000">{{days}} day{{daysS}}, {{hours}} hour{{hoursS}}, {{minutes}} minute{{minutesS}}</timer>
</div>

<div ng-if="x">
    <timer countdown="10041" max-time-unit="'minute'" interval="1000">{{hours}} hour{{hoursS}}, {{minutes}} minute{{minutesS}}</timer>
</div>

<div ng-if="y">
    <timer countdown="10041" max-time-unit="'minute'" interval="1000">{{minutes}} minute{{minutesS}}</timer>
</div>

<div ng-if="z">
    <timer countdown="10041" max-time-unit="'second'" interval="1000">{{sseconds}} second{{secondsS}}</timer>
</div>
siddii commented 7 years ago

I think you might be running into a issue of multiple timer on the same page. Possibly scope collisions?

Can you try it without ng-if?

Riccardo-Andreatta commented 7 years ago

How can I achieve what I want without a ng-if? Is there any options to do that?