It could be a service that has a postMethod
method that takes two arguments username and password just like this :
angular.factory('myService', ['$http', function($http){
function postMethod(username, password){
var request = {
method:'POST',
url: 'https://myurl.com/j_spring_security_check ',
data: {
username:username,
password:password
}
}
return $http(request);
}
return {
postMethod:postMethod
}
]);
Then you can use your service as following :
angular.module('myapp').controller('MainCtrl', ['myService', function(myService){
myService.postMethod('foo', 'bar').then(function(response){
// Do a UI change ?
});
}]);