I'm very new to angular and trying to create a controller that will get all of the Snods that belong to the current user. I have included my CurrentUserController for reference but my question is really about the SnodController, is the way I have injected the CurrentUser and nested the calls correct, because although it works it looks wrong to me.
Apologies if this is a matter for debate and against the rules, but I wanted to get an indication as to whether I was heading in the right direction with my approach.
var apiService = angular.module("apiService", ['ngResource']);
apiService.factory('CurrentUser', function($resource) {
return $resource( "http://snodbert/api/v1/users/current/", {});
});
apiService.factory('Snod', function($resource) {
return $resource
( "http://snodbert/api/v1/snods/:filter/:filterid", {}
, { 'update': { method:'PUT' }
}
);
});
function CurrentUserController($scope, CurrentUser) {
var user = CurrentUser.get(function() {
$scope.user=user;
}
);
}
function SnodController($scope, Snod, CurrentUser) {
var user = CurrentUser.get(function() {
var items = Snod.get( {filter:'owner', filterid: user.id},
function() {
$scope.items=items.data;
});
});
}