简体   繁体   English

使用onsen-ui在控制器中使用设备uuid

[英]use device uuid in controller using onsen-ui

i'm building a app using angularjs and onsen-ui in the Monaca cloud based development tool. 我正在基于Monaca云的开发工具中使用angularjs和onsen-ui构建应用程序。 this works great, but i can not figure out how to get device params like UUID into a controller. 这很好,但我不知道如何将设备参数(如UUID)放入控制器。

I initialize onsen using : 我使用以下方法初始化温泉:

var module = ons.bootstrap('my-app', ['onsen']);

then for example i have a main controller like this: 那么例如我有一个像这样的主控制器:

module.controller('MainController', function($scope) {

    $scope.deviceid = device.model;

});

in this example device.uuid is ofcourse not working. 在此示例中,device.uuid当然不起作用。 does anybody know how to access these device params? 有人知道如何访问这些设备参数吗?

i included the cordova device plugin. 我包括了cordova设备插件。

You can get all the device proprieties, like the UUID, in this way: 您可以通过以下方式获得所有设备的专有属性,例如UUID:

 <!DOCTYPE html> <html ng-app="my-app"> <head> <title>Device Properties Example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> var module = ons.bootstrap('my-app', ['onsen']); module.controller('MainController', function($scope) { // Wait for device API libraries to load // document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { var element = document.getElementById('deviceProperties'); element.innerHTML = 'Device Name: ' + device.name + '<br />' + 'Device Cordova: ' + device.cordova + '<br />' + 'Device Platform: ' + device.platform + '<br />' + 'Device UUID: ' + device.uuid + '<br />' + 'Device Model: ' + device.model + '<br />' + 'Device Version: ' + device.version + '<br />'; } }); </script> </head> <body> <p id="deviceProperties">Loading device properties...</p> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM