Error: Can't find variable: WindowsAzure
Error: Can't find variable: WindowsAzure
我正在将 Azure 移动服务与 ionic 一起使用,我正在尝试在工厂中将我的客户端创建为单例。但是,当尝试像往常一样使用客户端时,我不断收到此错误错误:找不到变量: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 = "";
};
}])
因此,在调查错误但未找到任何结果后,我决定通过在索引中添加脚本来手动添加移动服务插件,现在效果很好!感谢您的帮助
您需要确保应用处于 "ready" 状态(即加载所有 JavaScript 库)。在Ionic中,最好使用工厂来保证单例。这也将向您保证它会在正确的时间加载。
我正在将 Azure 移动服务与 ionic 一起使用,我正在尝试在工厂中将我的客户端创建为单例。但是,当尝试像往常一样使用客户端时,我不断收到此错误错误:找不到变量: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 = "";
};
}])
因此,在调查错误但未找到任何结果后,我决定通过在索引中添加脚本来手动添加移动服务插件,现在效果很好!感谢您的帮助
您需要确保应用处于 "ready" 状态(即加载所有 JavaScript 库)。在Ionic中,最好使用工厂来保证单例。这也将向您保证它会在正确的时间加载。