sampart / cordova-plugin-app-version

Cordova plugin to return the version number of the current app [not maintained]
MIT License
401 stars 195 forks source link

Nothing is working in page after calling appversion #102

Closed vishalv26 closed 6 years ago

vishalv26 commented 6 years ago

example :

alert(this.file.externalCacheDirectory); //returns proper directory when called above
this.appVersion.getPackageName().then(function (getPackageName) {
alert(getPackageName);
});

bit not getting alert if called like this

this.appVersion.getPackageName().then(function (getPackageName) {
alert(this.file.externalCacheDirectory);

});

i assume it clears everything in this.* if called once

DennisSmolek commented 6 years ago

Im guessing your scope for this inside the promise refers to that function and not the outer scope.

DennisSmolek commented 6 years ago

try:

var that = this;
this.appVersion.getPackageName().then(function (getPackageName) {
    alert(that.file.externalCacheDirectory);
});