I tried a lot of solutions I found to solve my issue but probably not the good one. Hope someone could help me
I launched an Ionic project, and i need to get the UUID.
I installed ngCordova with bower and did all the Install paragraph said here : ngCordova website
Here is my app.js file:
I just added ngCordova at the angular.module line, and added $cordovaDevice in the run method
FYI :
I already called the ng-cordova.js script in the index.html file.
The device plugin is installed
And here is my console log error :
Uncaught ReferenceError: device is not defined
Does someone have any idea to resolve it ?
Many thanks.
I place the following snuppet in $ionicPlatform.ready, like you did, i go like this and put my values in a variable that I got called appData.state. but you could put it elsewhere or to the consoleā¦ hope this helps. :
Thank you for your answer boltex.
Unfortunately, your example donāt work for me. That tells me the same thing : device is not defined and i really donāt understand why.
Maybe i forgot something somewhere in the code. Is it possible for you to give me please a little piece of your code that works with ngCordova that i can test ?
I added ngCordova before cordova.js. I reproduced all the step described in the documentation but that didnāt work ā¦
I found a solution to get around my issue but this is not the one i wanted.
I now launch the command phonegap serve rather than ionic serve. I put the .cordova folder (generated with phonegap) at the root of the project generated by ionic. And i donāt use ngCordova anymore, but the ānativeā plugins give by phonegap.
If you have any solution to help me to use ngCordova with ionic, iād be delighted to hear
If you did a custom download of ngCordova, there are several errors in their output that you will need to fix, I got that error because of the module naming being incorrect.
I have the same problem all I am trying to do is
try{
$scope.main.MyUUID=$cordovaDevice.getUUID();
}
catch(err){$scope.main.MyUUID=ātestā;
alert(err.message);}
}
And the alert is Device is not defined. Even when I run it on my android phone.
the top is like this to allow ngCordova and $cordovaDevice
angular.module(āstarter.controllersā,[āngCordovaā])
.controller(āhttpLoginā, [ā$scopeā,ā$httpā,āDSP_URLā,ā$ionicLoadingā,ā$cordovaDeviceā, function ($scope,$http,DSP_URL,$ionicLoading,$cordovaDevice) {
and my library loads are in this order
src=ācordova.jsā>
src=ālib/ionic/js/ionic.bundle.jsā>
src=ālib/ngCordova/dist/ng-cordova.jsā>
src=ājs/app.jsā>
src=ājs/controllers.jsā>
src=ājs/services.jsā>
Hi,
I tried your solution @boltex and that works. I only tried the āionic serveā command, thatās why that didnāt work.
Many thanks for your help
offtopic: how do you confirm a selected option of a select control if you call Keyboard.hideAccessoryBar(true)? It seems a bit problematic. We regret to manage a virtual keyboard at all, as many issues are raised after that.
Can you provide a detail way of how you fixed this problem? I have the same ādevice is not definedā error message when trying to collect the device info.