Currently, I am working on implementing a feature in Angular2 that relies on the use of setTimeout
.
This is a snippet of my code:
public ngAfterViewInit(): void {
this.authenticate_loop();
}
private authenticate_loop() {
setTimeout (() => {
console.log("Hello from setTimeout");
}, 500)
}
Although setTimeout
is triggered by ngAfterViewInit
, the loop only runs once, displaying "Hello from setTimeout" just one time.
Inquiry: What modifications can be made to enable setTimeout
to function properly?