【发布时间】:2016-03-14 15:27:12
【问题描述】:
我在 agularjs 中编写了一个简单的控制器来处理表单提交。使用 ng-submit 提交表单。
服务器正在成功处理 post 请求并返回 http 状态 200。 但是 AngularJs 再次使用 POST 方法调用当前页面 url,这导致服务器返回 MethodNotAllowedException (Laravel 5.2) 页面。
这是控制器代码。
app.controller('adminAddController', ['$scope', '$http', 'Page', function($scope, $http, Page){
$scope.formData = {};
$scope.processForm = function($event) {
console.log($scope.formData);
$http({
method : "post",
url : 'http://localhost:8000/api/blogs',
data : $scope.formData,
})
.then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
console.log(response);
});
};
}]);
【问题讨论】:
-
你能展示你的表单元素吗?
-
请粘贴您的表单代码。
标签: javascript angularjs