我在角度应用程序中收到400(错误请求)错误。
提交用户详细信息customerLoginController.js:10
POST http://localhost:8080/login
400(错误请求)angular.min.js:77
上传错误
目前正在发生的事情是我可以看到我的console.logs正在通过,但数据没有通过客户用户名和密码。
我的代码在表单中,然后在我的控制器中:
<div class="loginForm" ng-controller="customerLoginController">
<form method="POST">
Username: <br />
<input type="text" placeholder="Enter your username" ng-model="customer.username" /><br /><br />
Password: <br />
<input type="password" placeholder="Enter your password" ng-model="customer.password" />
<span class="promptDetails" ng-click="getUserCredentials()"><a ui-sref="#" class="fetchLogDetails">Forgot login details</a></span>
<br />
<input type="button" id="loginUser" value="Login" ng-click="login(customer)" />
</form>
</div><!-- End login form -->
表单的控制器
angular
.module('customerProfile')
.controller('customerLoginController', function($scope, $http, $location) {
$scope.customer = {
username: '',
password: ''
},
$scope.login = function(customer) {
console.log("Submitting user details");
$http.post('http://localhost:8080/login', customer)
.success(function(data, status, headers, config) {
console.log(msg.data);
})
.error(function() {
console.log("Error in upload");
})
};
})