Angular 2 multiple countdown pipe

Viewed 4670

I'm looking to create angular 2/4 countdown pipe.

Of course I can make individual countdowns, but how do I create multiple ones?

I want the following input:

<span [time]="unix timestamp here">Countdown will count here</span>

for example:

<span [time]="1500503492">Countdown will count here</span>
<span [time]="15005034392">Countdown will count here</span>
<span [time]="1500503492">Countdown will count here</span>

How can I achieve that all would work no matter how many I have?

What I tried so far is only single countdowns like the following:

time = 30;
setInterval(() => {
  this.currentTime = new Date().getTime();
  if (this.time > 0) {
    this.time = this.time - 1;
  }
}, 1000);

{{ time}}
1 Answers
Related