I’m no expert.
Sorry if the question is insignificant, but as I’m learning to ask.
How to use native ionic 2, in the following situation:
How to print in html(AppVersion.getVersionCode();)?
What is the process to get the result? Will the constructor? Could you give me a simple example of use? The way that the documentation I could not understand.
in .js
import {AppVersion} from ‘ionic-native’;
AppVersion.getAppName();
AppVersion.getPackageName();
AppVersion.getVersionCode();
AppVersion.getVersionNumber();
in .html
<ion-card-content> {{VERSAO}} </ion-card-content>
I have already installed the plugin in my project.
$ ionic plugin add cordova-plugin-app-version
I think all those functions return a promise rather than a value. Try something like this in your constructor:
this.versionNumber = 'unknown';
if(this.platform.is('cordova')) {
AppVersion.getVersionNumber().then((s) => {
this.versionNumber = s;
})
}
and then use
{{versionNumber}}
in your html template.
The “platform.is” wrapper is to avoid errors if you’re testing in a browser.
1 Like
Thank you fuffenz, I will test .
I think the documentation lack a better example. Especially for those who are learning .
hey i tried above code but i getting problem …in my case version get but when i assign version to variable didn’t work
AppVersion.getVersionNumber().then((s) => {
console.log(‘ver’,s);
this.fetchData = s;
});
in above code ‘s’ value print proepr but when i print this.fetchData…print undefined
Might be a scope problem, are you sure “this” is referring to the correct namespace?
this thread is 2 years old
My bad, I only saw „3 month“ on top of the comment and misstook it for the age.