I am unsure if I am sending the username and password in JSON format correctly. As a beginner in Angular, I want to make sure I am doing it right.
myApp.controller('loginController',['$scope','$http', function($scope, $http)
{
$scope.email = "" ;
$scope.password = "" ;
$scope.loginForm = function(){
alert("login controller called");
console.log($scope.email);
console.log($scope.password);
var encodedString = 'email=' +
encodeURIComponent($scope.email) +
'&password=' +
encodeURIComponent($scope.password);
$http({
method:'POST',
url: 'rs/loginResource',
data: encodedString,
headers: {'Content-Type' : 'application/json'}
});
};
}]);
When inspecting the POST header using Firefox, I noticed that the username and password are displayed as plain parameters rather than in JSON format. Currently, I am using encodeURIComponent, but I would like to send them as JSON. How can I achieve this?