2017-04-26 69 views
0

我正在使用Azure移動服務與離子,我試圖創建我的客戶在工廠作爲一個單身人士。然而,當試圖像我通常那樣使用客戶端時,我一直得到這個錯誤錯誤:無法找到變量:WindowsAzure。先謝謝你。錯誤:無法找到變量:WindowsAzure

.factory('client', [function(){ 
var myjsonObj = new WindowsAzure.MobileServiceClient('https://xxx.azurewebsites.net'); 
return myjsonObj; 
}]) 

控制器,我把它叫做

.controller('loginCtrl', ['$scope', '$stateParams', 'md5', 'Userid', '$state','$ionicSideMenuDelegate','$ionicLoading','client',// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller 
// You can include any angular dependencies as parameters for this function 
// TIP: Access Route Parameters for your page via $stateParams.parameterName 
function ($scope, $stateParams,md5,Userid,$state,$ionicSideMenuDelegate,$ionicLoading,client) { 

$scope.UserInfo = {}; 

$ionicSideMenuDelegate.canDragContent(false); 


    $scope.show = function() { 
    $ionicLoading.show({ 
     template: '<p>Loading...</p><ion-spinner></ion-spinner>' 
    }); 
    }; 

    $scope.hide = function(){ 
     $ionicLoading.hide(); 
    }; 

$scope.login =function(){ 

$scope.show($ionicLoading); 








    if ($scope.UserInfo.password == null){ 
     $scope.UserInfo.password = "fa"; 
    } 




    var query = client.getTable('clubUser') 
    .where({ Email: $scope.UserInfo.email, Password: md5.createHash($scope.UserInfo.password) }) 
    .read() 
    .done(function(results) { 


     if(results[0] == undefined) 
     { 

      $scope.errorText = "Error: Wrong Username/Password"; 
      $scope.$apply(); 
      $scope.hide($ionicLoading); 
     } 
     else 
     { 
      $scope.hide($ionicLoading); 
      Userid.setJson(results[0].id); 

      $state.go('tabsController.qRCode'); 

     } 




    }, function(error) { 

     console.dir(error); 
     $scope.hide($ionicLoading); 
    }); 

$scope.UserInfo.password = ""; 




}; 



}]) 
+0

看來,該腳本未加載。你在使用npm軟件包還是腳本? –

+0

我在cmd中找到了我的項目,並使用cordova插件添加了cordova-plugin-ms-azure-mobile-apps進行安裝。 @Volodymyr Bilyachat – Dedawg

+0

科爾多瓦插件只適用於手機,我假設你在瀏覽器中運行它是嗎? –

回答

1

尋找到了錯誤,並沒有找到任何結果後,所以我決定通過添加腳本來手動添加插件的移動服務我索引,現在它工作得很好!感謝您的幫助

0

您需要確保應用程序處於「就緒」狀態(即加載所有JavaScript庫)。在Ionic中,最好使用工廠來確保單身。這也可以保證它在正確的時間加載。

相關問題