2014-12-05 272 views
1

嗨,我正在開發一個混合應用程序使用離子框架和科爾多瓦。我正在使用設備uuid作爲ID,所以我添加了cordova設備插件。此外,我使用NG-Cordova包裝來呼叫我的科爾多瓦插件。但是,無論何時我在xcode模擬器或實際的Ipad上運行我的應用程序,我都會獲得{{uuid}}。離子科爾多瓦設備UUID

似乎有不被任何錯誤消息我只能假設該設備插件不工作。

我已經把我的代碼如下但是林不知道這是問題,有沒有人有這個問題,他們是怎麼解決它之前,如果是這樣?

控制器:

angular.module('starter.controllers', []).controller('DashCtrl', function(
$scope, $state, $cordovaDevice) { 
var init = function() { 
    console.log("initializing device"); 
    try { 
     $scope.uuid = $cordovaDevice.getUUID(); 
    } catch (err) { 
     console.log("Error " + err.message); 
     alert("error " + err.$$failure.message); 
    } 
}; 
init(); 

})

的Html

<ion-view title="Dashboard"> 
    <ion-content class="padding"> 
    <h1>Dash</h1> 
    {{uuid}} 
    </ion-content> 
</ion-view> 

app.js

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) 
    .run(function($ionicPlatform) { 
     $ionicPlatform.ready(function() { 
      if (window.cordova && window.cordova.plugins.Keyboard) { 
       cordova.plugins.Keyboard.hideKeyboardAccessoryBar(
        true); 
      } 
      if (window.StatusBar) { 
       // org.apache.cordova.statusbar required 
       StatusBar.styleDefault(); 
      } 
     }); 
    }).config(function($stateProvider, $urlRouterProvider) { 
     $stateProvider 
     // setup an abstract state for the tabs directive 
      .state('tab', { 
       url: "/tab", 
       abstract: true, 
       templateUrl: "templates/tabs.html" 
      }) 
      // Each tab has its own nav history stack: 
      .state('tab.dash', { 
       url: '/dash', 
       views: { 
        'tab-dash': { 
         templateUrl: 'templates/tab-dash.html', 
         controller: 'DashCtrl' 
        } 
       } 
      }); 
     // if none of the above states are matched, use this as the fallback 
     $urlRouterProvider.otherwise('/tab/dash'); 
    }); 
+0

是一個錯字或是你真的錯過ng控制器? – 2014-12-05 10:41:42

+0

我不需要NG-控制器,因爲其所謂的路線...對不起應該說的很清楚 – Adam 2014-12-05 10:46:59

+0

更新的問題,包括我的app.js文件 – Adam 2014-12-05 10:49:34

回答

1

背後我的問題的原因是由於使用的自定義生成ngCordova。

,如果我只是ngcordova的正常或縮小的版本,它完美的作品。

感謝您的幫助。