如何从 Controller 发送变量 year, monthGet 功能 Angular 服务?
服务
myApp.factory('getJsonForCalendarService', function($resource, year, monthGet) {
return $resource(
'../rest/api.php',
{ method: 'getJsonForCalendar', year: year, monthGet:month},
{'query': { method: 'GET', isArray: true }}
);
});
Controller
$scope.getJsonForCalendar = getJsonForCalendarService.query(function (response, year, monthGet) {
});
最佳答案
你的工厂函数只会被应用程序注入(inject)器实例化(调用/新建)一次:你需要这样做:
myApp.factory('getJsonForCalendarService',function($resource){
return function(year,month){
return $resource(
'../rest/api.php',
{ method: 'getJsonForCalendar', year: year, monthGet:month},
{'query': { method: 'GET', isArray: true }}
);
}
}
关于javascript - 如何发送变量函数 Angular 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20455150/