i use method setTimeout in my users.component.ts but does not work and get cannot find module 'timers' error
i import this code but does not work
import { setTimeout } from 'timers'
I have used SetInterval function, Also remove the import statement that is autogenerated.
Ex :
import { Component, OnInit } from '@angular/core';
//import { setInterval } from 'timers';
export class HelloWorldComponent implements OnInit {
message : string ;
constructor() {
setInterval(() => {
let currentDate = new Date();
this.message = currentDate.toDateString() + " " + currentDate.toLocaleTimeString();
}, 1000);
}
ngOnInit() {
}
}
Whenever you are using the setTimeout in our code,import { setTimeout } from 'timers'
then this import we will get by autogenerating code, once remove this import statement and run the code it should work, for me working fine.
`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With