2016-02-23 118 views
0

無法在視圖來獲取設備信息 -使用ionic.Platform獲取設備信息

angular.module('PlatformApp', ['ionic']) 
.controller('PlatformCtrl', function($scope) { 

    ionic.Platform.ready(function(){ 
// will execute when device is ready, or immediately if the device is already ready. 
    }); 

var deviceInformation = ionic.Platform.device(); 
}); 

我如何從VAR deviceInformation設備信息?

我知道deviceInformation.model將檢索設備的型號名稱 - 但離子網站上的指南並未顯示如何完成此操作?我似乎嘗試的一切看起來並沒有工作得到空白/空的對象。

http://ionicframework.com/docs/api/utility/ionic.Platform/

+0

http://ngcordova.com/docs/plugins/device/ –

+0

你在設備或瀏覽器 –

+0

都測試:(我會稍後張貼更多的代碼 – Zabs

回答

0

您需要將您的代碼在平臺準備像如下。

$ionicPlatform.ready(function() { 
    $scope.deviceInformation = ionic.Platform.device(); 
    }); 

,你將可以與設備信息在你的控制器:

$scope.getDeviceInfo = function() { 
    alert($scope.deviceInformation.uuid); 
} 

欲瞭解更多信息,一些如何類似的問題都可以在這個link

希望這會幫助你!