错误:无法找到变量:WindowsAzure

问题描述:

我正在使用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

科尔多瓦插件只适用于手机,我假设你在浏览器中运行它是吗? –

寻找到了错误,并没有找到任何结果后,所以我决定通过添加脚本来手动添加插件的移动服务我索引,现在它工作得很好!感谢您的帮助

您需要确保应用程序处于“就绪”状态(即加载所有JavaScript库)。在Ionic中,最好使用工厂来确保单身。这也可以保证它在正确的时间加载。