I'm new to Angualrjs and I'm trying to figure out this code... this is how the service looks like
var userGroupServices = angular.module('userGroupServices', ['ngResource']);
userGroupServices.factory('UserRoles', ['$resource', function ($resource) {
var r1 = $resource('/api/UserRoles/:UserRoleId', null, {
'update': { method: 'PUT' },
'delete': { method: 'DELETE' }
});
r2 = $resource('/api/UserRoles', null, {
'add': { method: 'POST' },
'getRoles': { method: 'GET' }
});
r3 = $resource('/api/UserRoles/GetRolesByGroupType/:groupTypeName', null, {
'getRolesByName': {method:'GET'}
});
r1.getAll = r2.getRoles.bind(r2);
r1.add = r2.add.bind(r2);
r1.getRolesByName = r3.getRolesByName.bind(r3);
return r1;
}]);
Why is it in the end, you bind r2 and r3 variables into r1 variable? how do i use this factory to POST something, i try to post it like this way but it didn't do anything(in my controller)...
addService.addRole({ roleName: groupTypeName });