6
我app.js
看起來像AngularJS:服務查詢返回結果爲零
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
什麼,我做錯了什麼?
吉茲:(,我怎麼會錯過在文檔中的部分非常感謝你@joakimbi,它現在有效 – daydreamer 2013-05-06 03:27:32