Inappbrowser is not works within set timeout

this.platform.ready().then( () => {

  setTimeout(function () {
      const browser = this.iab.create("https://www.awebsite.co.uk", '_self', options)
}, 25);

})

if I write this.iab.create outside of setTimeout, it works , but inside of it it’s not opened!
I should use setTimeout…
how can I solve this problem?

if you do a console.log('test'); inside the setTimeout, does it gets printed?

Look up function scopes for this one.

by using the keyword function, you are creating an isolated context. Meaning that anything inside there has no access variables declared outside.

Instead use an arrow function instead. This will maintain lexical scoping.

setTimeout( ()=> {}, 25);
2 Likes