How to pass 'this' into a promise without caching on the street?

I have a variable called LangDataService.isDataReady , which is a Promise wawiting solution. After elimination there will be logic. How can I convey this to this promise?

 LangDataService.isDataReady.then(function () { this.modalOn() }); 

I know that I can cache var self_ = this; but am I curious about other alternatives?

+9
source share
1 answer
 LangDataService.isDataReady.then(function () { this.modalOn() }.bind(this)); 
+20
source

Source: https://habr.com/ru/post/1240724/


All Articles