我的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
我在这里做错了什么?