My code:
export class WordService {
constructor(private http:Http, private storage:Storage){}
impulseData={
get():Promise<any>{
return this.storage.get('impulseData');
}
};
}
When I call myWordService.impulseData.get(), I found this.storage is undefined. So how can I reach the property storage inimpulseData.get?
I guess this problem was caused by the scoping of this. Maybe I should let the this inside and outside impulseData share the same scope?
Update:
Thanks to Suren Srapyan's answer, I finally change my code to this:
impulseData={
get:()=>{
return this.storage.get('impulseData');
}
};