Angularjs 在Angular phonegap应用程序中使用Azure移动服务
我是angularJS的新手,我正在尝试在angularJS phonegap应用程序中使用azure移动服务。我发现了这个“azure移动服务” 但在第三步上被卡住了:Angularjs 在Angular phonegap应用程序中使用Azure移动服务,angularjs,cordova,visual-studio-2013,azure-mobile-services,onsen-ui,Angularjs,Cordova,Visual Studio 2013,Azure Mobile Services,Onsen Ui,我是angularJS的新手,我正在尝试在angularJS phonegap应用程序中使用azure移动服务。我发现了这个“azure移动服务” 但在第三步上被卡住了: angular.module('myapp', ['myApp.controllers', 'myApp.services', 'azure-mobile-service.module']); 这是我的原始代码: (function(){ 'use strict'; var module = angular.module(
angular.module('myapp', ['myApp.controllers', 'myApp.services', 'azure-mobile-service.module']);
这是我的原始代码:
(function(){
'use strict';
var module = angular.module('app', ['onsen']);
module.controller('AppController', function($scope, $data) {
$scope.doSomething = function() {
setTimeout(function() {
alert('tappaed');
}, 100);
};
});
module.controller('DetailController', function($scope, $data) {
$scope.item = $data.selectedItem;
});
module.controller('MasterController', function($scope, $data) {
$scope.items = $data.items;
$scope.showDetail = function(index) {
var selectedItem = $data.items[index];
$data.selectedItem = selectedItem;
$scope.ons.navigator.pushPage('detail.html', {title : selectedItem.title});
};
});
module.factory('$data', function() {
var data = {};
data.items = [
{
title: 'Item 1 Title',
label: '4h',
desc: 'Lorem ipsum dolor sit amet'
},
{
title: 'Another Item Title',
label: '6h',
desc: 'Ut enim ad minim veniam.'
},
{
title: 'Yet Another Item Title',
label: '1day ago',
desc: 'Duis aute irure '
},
{
title: 'Yet Another Item Title',
label: '1day ago',
desc: 'Duis aute irure.'
}
];
return data;
});
})();
这是我的文件结构:
如何在我的项目中使用此“angular azure移动服务”?任何帮助都将不胜感激!谢谢 首先,在模块中添加一个角度常数
angular.module('myapp', ['azure-mobile-service.module'])
.constant('AzureMobileServiceClient', {
API_URL : 'https://<your-azure-service>.azure-mobile.net/',
API_KEY : '<your-azure-service-API-KEY>',
})
angular.module('myapp',['azure-mobile-service.module']))
.constant('AzureMobileServiceClient'{
API_URL:'https://.azure-mobile.net/',
API_密钥:“”,
})
接下来,将Azureservice添加到控制器、服务等
.service('myApp.service', function(Azureservice) {
this.init = function () {
/* Replace the <my-table-name> with the name of the table in your Azure database. You can use any of the Azureservice methods at this point */
Azureservice.getAll('<my-table-name>')
.then(function(items){
$scope.items = items;
}, function(err){
console.error(err);
});
}
})
.service('myApp.service',函数(Azureservice){
this.init=函数(){
/*将替换为Azure数据库中表的名称。此时,您可以使用任何Azureservice方法*/
Azureservice.getAll(“”)
.然后(功能(项目){
$scope.items=项目;
},函数(err){
控制台错误(err);
});
}
})
依赖项注入确保azure-mobile-service.module被注入到您的“myApp.service”中。然后,您可以使用Azureservice方法的一部分来访问您的数据
请注意:必须根据文件指定AzureMobileServiceClient名称和Azureservice对象名称,否则DI将失败