Something seems off with my form reset after a ng-click event, am I missing something?
I can successfully submit the form, but it doesn't automatically reset. Here is the error message I receive:
angular.js:12701 POST 500 (Internal Server Error)
The post submission works fine, but the form doesn't clear out as expected.
Check out this jsfiddle link for reference:
https://jsfiddle.net/2fyynf6p/
Here's the main.js code snippet:
var app = angular.module('eli', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
app.controller('mainCtrl', ['$scope', '$http', function($scope, $http){
$scope.posts = {};
$scope.addPost = function(){
$http.post('/auth/post', {
title: $scope.post.title,
body: $scope.post.body
}).then(function(data, status, headers, config){
$scope.posts.push(data);
$scope.postform = "";
});
};
}]);
And here's the html code snippet:
<form name="postform" method="POST" novalidate>
{{ csrf_field() }}
<div class="form-group">
<label for="post.title">Title</label>
<input ng-model="post.title" class="form-control" type="text" name="title" placeholder="Enter a title" required/>
</div>
<div class="form-group">
<label for="post.title">Post</label>
<textarea ng-model="post.body" type="text" class="form-control" name="body" id="" cols="10" rows="5"></textarea>
</div>
<button id="eli-style-button" ng-click="addPost()" class="btn btn-primary" type="submit">Submit</button>
</form>