本文介绍了如何在ionic框架中获取设备UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过以下方式安装了cordova设备插件:

installed cordova device plugin by :

sudo cordova plugin add org.apache.cordova.device

然后下载 ngCordova 并将 ng-cordova.min.js 包含到 js 文件夹中,也包含在 index.html 中

then downloaded ngCordova and included ng-cordova.min.js in to js folder and also included in index.html

接下来我做的是注入ngCordova如下

next what i did is injected ngCordova as follows

angular.module('starter', ['ionic', 'starter.controllers','ngCordova'])

然后按如下方式包含在控制器中

then included in controller as follows

angular.module('starter.controllers', [])

.controller('AppCtrl', function($scope, $ionicModal, $timeout, $ionicPlatform,$cordovaDevice)
but still getting the following errors

ReferenceError: device is not defined
at Object.getUUID (http://localhost:8100/js/ng-cordova.min.js:1:14929)
at new <anonymous> (http://localhost:8100/js/controllers.js:27:26)
at invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11591:17)
at Object.instantiate (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11602:23)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:14906:28
at updateView (http://localhost:8100/lib/ionic/js/ionic.bundle.js:42986:30)
at eventHook (http://localhost:8100/lib/ionic/js/ionic.bundle.js:42933:17)
at Scope.$broadcast (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20605:28)
at $state.transition.resolved.then.$state.transition (http://localhost:8100/lib/ionic/js/ionic.bundle.js:34122:22)
at wrappedCallback (http://localhost:8100/lib/ionic/js/ionic.bundle.js:19197:81)

现在你能告诉我出了什么问题吗?

Can you now tell me what went wrong?

如果有另一种读取设备 UUID 的方法,请告诉我它的方向.

If is there another way to read the Device UUID show me the direction to it.

推荐答案

wow 发现我做错了什么...通过这个问题.http://forum.ionicframework.com/t/problem-to-use-ngcordova-device-is-not-defined/11979

wow found out what wrong i was doing... through this question. http://forum.ionicframework.com/t/problem-to-use-ngcordova-device-is-not-defined/11979

当我们在具有其他平台而不是cordova支持的其他设备上进行测试时,会发生这种情况.这对我来说是一个有用的发现.

when we test on other device which has other platform than cordova supports this happens.this was a useful discovery for me.

这篇关于如何在ionic框架中获取设备UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-28 13:36