I have a div that contains click event, here once I click "click here" label alert should come based on 2 condition, first one if getListData is true and second one if I click the label only after 5 sec of getListData is true. I have tried but its not working properly. Here is the code below
home.component.html
<div (click)="clickhere()">Click here</div>
home.component.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
getListData: boolean = false;
constructor(private router: Router) { }
ngOnInit() {
}
clickhere(){
this.getListData = true;
console.log(this.getListData);
setTimeout(function(){
if(this.getListData == true){
alert('true');
}
}, 3000);
}
}