我的问题在下一段代码中描述:
var eventModule = angular.module('eventModule', ['ngResource']);
eventModule.factory('Event', ['$resource',
function($resource){
return $resource('http://cip-cirip.ro/API/events/:eventId', {}, {
query: {method:'GET', params:{eventId:'55'}, isArray:false}
});
}
]);
eventModule.controller('events_interface', function ($scope, $http){
//$scope.events = [{id:1, name:'evenimentul 1'},{id:2, name:'evenimentul 2'}];
var ev = Event();
console.log(ev);
$scope.events = ev.query();
});
答案 0 :(得分:2)
您需要将服务作为依赖项注入,无论您何时需要访问它:
eventModule.controller('events_interface', function ($scope, $http, Event){...