I am creating my first component using angular, its a countdown, but i don't know how show results on template
I have tried just using {{}}but nothing happens
thanks for your help ...............................................................................................................................................................................................................................................
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-countdown',
templateUrl: './countdown.component.html',
styleUrls: ['./countdown.component.css']
})
export class CountdownComponent implements OnInit {
mi_funcion () {
let x = setInterval(function():void{
let now = new Date().getTime();
let countDownDate:number = new Date ("Jan 5, 2021 15:37:25").getTime();
let distance: number = countDownDate - now
let days:number = Math.floor(distance / (1000 * 60 * 60 * 24));
let hours:number = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes:number = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
let seconds:number = Math.floor((distance % (1000 * 60)) / 1000);
//console.log( `Faltan: ${days} Dias, ${hours} Horas, ${minutes} Minutos, ${seconds} Segundos`);
if (distance < 0){
clearInterval(x);
console.log("El tiempo para preventa he terminado");
}
},1000);
}
ngOnInit() {
}
}
let instancia = new CountdownComponent();
instancia.mi_funcion()
//And html
<div class="row">
<div class="col-3">Dias: {{days}}</div>
<div class="col-3">Horas: {{hours}}</div>
<div class="col-3">Minutos: {{minutes}}</div>
<div class="col-3">SegundoS: {{seconds}}</div>
</div>