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”>
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.