I want to login using $http and GET of REST web services. What I am doing is:
- Taking data on the basis of username and password using $http.get
- Storing the result:
$scope.getResult=res; Storing it in some variable:
var result=$scope.getResult; var username=result.userName;
var password=result.password;
var user=this.user; var pass=this.pass;After that I will compare with the ng-model of username and password. If it is successful then it will redirect to another page like below:
if (username == user && password == pass) { window.location="/next.html";
}
Below is my complete code and please suggest the changes required in my case.
$scope.login = function () {
var user = this.user ; // ng-model of username in html page
var pass = this.pass; //ng-model of password in html page
$http.get("http://localhost:17681/api/userRegisters"+user+pass).success(function (res) {
$scope.getResult = res;
var result = $scope.getResult;
var username = result.userName;
var password = result.password;
if (username == user && password == pass) {
window.location="/next.html";
}
}
}
Please tell me how should I change my code in order to do that.
Thanks in advance :)
"http://localhost:17681/api/userRegistersusernamepassword", put in some slashes$http.postrequest instead of a get