Hello I need to find/update users from a mongodb collections via angular. And I need to find them by _id and by username, so I created a service like this:
// Users service used for communicating with the users REST endpoint
angular.module('users').factory('Users', ['$resource',
function($resource) {
return $resource('users/:id', {}, {
update: {
method: 'PUT'
}
});
}
]);
And on Express I have the relative API route:
app.route('/users/:userId').put(users.update);
Now, suppose I have another express route like this to check username availability:
app.route('/users/:username').get(users.check);
How can I integrate this last one in the same angular service?
UPDATE: Solved with this, is it right?
angular.module('users').factory('Users', ['$resource',
function($resource) {
return {
byId: $resource('users/:id', {}, {
update: {
method: 'PUT'
}
}),
byUsername: $resource('users/:username', {}, {
})
};
}
]);