2016-04-04 83 views
0

我在這裏瘋了。我是離子開發的新手,並試圖安裝一個星期的任何插件...所以爲了簡單起見,這是我在本地在Git Bash上做的,也嘗試了從Linux服務器運行。ngCordova - cordova.plugins not defined

1. NodeJs installed 
2. Cordova installed, tried it with verions 5.4.1, 6, 6.1 
3. Ionic 1.7.14 installed 
4. ionic start sideApp sidemenu - success 
5. android platform added 
6. bower install ngCordova - success 

的index.html:

<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
    <title></title> 

    <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above 
    <link href="css/ionic.app.css" rel="stylesheet"> 
    --> 

    <!-- ionic/angularjs js --> 
    <script src="lib/ionic/js/ionic.bundle.js"></script> 

    <script src="lib/ngCordova/dist/ng-cordova.min.js"></script> 
    <!-- cordova script (this will be a 404 during development) --> 
    <script src="cordova.js"></script> 

    <!-- your app's js --> 
    <script src="js/app.js"></script> 
    <script src="js/controllers.js"></script> 
    </head> 

    <body ng-app="starter"> 
    <ion-nav-view ></ion-nav-view> 
    <div ng-controller="PlaylistsCtrl"></div> 
    </body> 

控制器

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

.controller('PlaylistsCtrl', function($ionicPlatform, $scope, $cordovaDevice, $window) { 
    $ionicPlatform.ready(function() { 
     if ($window.cordova)   
      alert('$window.cordova available'); 
     else 
      alert('$window.cordova NOT available'); 

     if ($window.cordova.plugins) 
      alert('$window.cordova.plugins available');   
     else 
      alert('$window.cordova.plugins NOT available'); 

    }); 
}) 

然後ionic upload,並在檢查手機時,無論我做什麼,我得到警報不avalialble

我錯過了什麼?它是否與某些版本存在兼容性問題,或者我可能會丟失什麼?我正試圖讓這個解決了一個字面上一個星期吧... 謝謝!

回答

2

我猜你正在檢查通過離子視圖應用程序,對(因爲你提到ionic upload)?

你不能在插件中使用它(與大多數插件不能通過瀏覽器工作的方式相同)。不,你不能,也不是沒有解決方法,它只是不打算處理。

如果您已經在應用程序商店中有應用程序,並且您試圖通過ionic upload部署熱代碼推送,那麼請記住您首先必須發送帶有新插件的更新(插件是二進制文件),然後才能再次使用熱代碼推送(部署)。底線,您應該通過ionic run的實際電話或通過模擬器ionic emulate測試您的插件。

+0

我也嘗試與離子發球,並與鉻檢查:/ /檢查/不應該工作??因爲我也有相同的undefined錯誤。 –

+0

不,它不應該。在真實設備或模擬器上測試你的插件。 – Nikola