Reputation: 572
Method
hola() {
return new Promise((resolve, reject) => {
if(true) {
resolve(true)
}
})
}
Calling the method
this.hola.then(data => console.log(data));
Error
Property 'then' does not exist on type '() => Promise<{}>'.
I already tried to restart ionic serve but it keeps throwing that error
Upvotes: 12
Views: 18772
Reputation: 591
The parenthesis is missing while you are calling the method hola.
this.hola().then(data => console.log(data));
Upvotes: 31
Reputation: 21
When you call the method, try this instead, storring it in a variable of type "any" makes it ignore the "existence" of the proprety
var a:any = this.slides.getActiveIndex()
a.then(data => {
console.log(data)
})
Upvotes: 2