I’m trying to display an ID I retrieve from a Cordova plugin in my Ionic 2 application. The problem is that I can display it in the console log but I cannot figure out how to display it in the Ionic view.
I am completly new to ionic and web things. So it is only a guess.
All examples I saw used a variable or a property to display in {{bla}}. So don’t know if a function is working. Maybe you can try to use a property or variable.
Do you mean the Ionic View app by that?
If so: Ionic View only supports a limited amount of plugins listed here: Ionic Docs - Ionic Documentation
To test your custom Cordova plugin you have to use ionic cordova run or a similar command to build your own app. (It’s not that difficult you once worked it out. Alternatively you can use Ionic Package to build in the cloud)
This is not going to work as you are trying to write it. It is impossible to synchronously return a value that is asynchronously generated.
If at all possible, please use the ionic-native shim for whatever this plugin is. Doing so will guide you naturally towards how to use the futures properly.
Sorry, to make it clear I mean the Ionic page rather than the Ionic View software haha. I’ve been testing on an actual device due to using my Cordova plugin.
I am using a native Android SDK for my Cordova plugin, therefore use of Ionic Native isn’t possible. The value of the ID is returned in the console.log so why can’t I display it on my Ionic page? Can you help?
Hello,
I am new to all these things.
But I think you can bind only to property (variables). Have you tried to declare your idNumber outside of function and bind this
I’ve tried that too, it doesn’t work. I believe it has something to do with what @rapropos stated. I’m also new to Ionic but the Cordova plugin is the difficult part
Hello,
okay let’s try something else. Give your element an Id
<p id="pwork">This Device id will overwriten </p>
```
add then after
```
console.log(idNumber);
(<HTMLParagraphElement> document.getElementById('pWork')).innerHTML = "Device Id: " + idNumber)
```
If innerHtml is not working you can try textcontent.
I use this in a similar case.
best regards, anna