Hi all. I need help.
Something is not evident to me about scope of variables in typescript.
I have an app that goes in background, and with a timer has to check a condition. But with setInterval
I can’t pass a value to the function, and the function can’t access the foreground environment (I guess).
Example (I hope I didn’t big error, this s a not tested code):
export class HomePage {
value: string
constructor(
private alertCtrl: AlertController,t,
private platform: Platform
) {
this.value = "something";
setInterval(this.test, 1000);
}
test() {
console.log(this.value)
}
console show undefined. Why??
Any help will be appreciated.