AngularJS: сервисный запрос, возвращающий нулевой результат
мойapp.js
похоже
var app = angular.module('pennytracker', [
'$strap.directives',
'ngCookies',
'categoryServices'
]);
app.config(function($routeProvider) {
console.log('configuring routes');
$routeProvider
.when('/summary', { templateUrl: '../static/partials/summary.html'})
.when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' })
});
пока мойapp/js/services/categories.js
похоже
angular.module('categoryServices', ['ngResource']).
factory('Category', function($resource){
return $resource(
'/categories/:categoryId',
{categoryId: '@uuid'}
);
});
и у меня есть маршрут как
.when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' })
и мой контроллерapp/js/controllers/transactionController.js
похоже
function AddTransactionController($scope, $http, $cookieStore, Category) {
// some work here
$scope.category = Category.query();
console.log('all categories - ', $scope.category.length);
}
Когда я запускаю свое приложение, я вижу console.log как
all categories - 0
Что я здесь не так делаю?