I'm trying to call a function from a 5-deep nested function in Typescript, and it's not able to see the outside function. Running console.log(this) inside of setTimeout returns the window object.
export class SearchComponent implements OnInit {
lifeCycleFunc(){ //Function 1
...
if() { //Function 2
....
var.do(item => { //Function 3
....
var.forEach(var => { //Function 4
...
setTimeout(function(){ //Function 5
this.searchFunc() //this.searchForAssignments is not a function
}
})
})
}
}
searchFunc(){
...
}
}