I came across this solution on a forum, but it lacks detailed explanation for me to customize it according to my requirements. The author also mentions a stack overflow question, which led to various "different" solutions leaving me feeling confused.
Below is the controller code snippet:
.controller('AppCtrl', function($scope, $http) {
$scope.data = {};
$scope.submit = function(){
var link = 'http://app.domain.com/api.php';
$http.post(link, {username : $scope.data.username}).then(function (res){
$scope.response = res.data;
});
console.log($http.post(link, {username : $scope.data.username}));
};
});
I plan to enhance the code by including an additional field for password along with the username and posting them to the server. However, I only require a single field in the response.
Could someone provide me with an explanation of the above code so that I can make the necessary modifications?