Is there a way to submit a form with AngularJs without using an asynchronous call? I'd like it to act as if I hit the submit button on a regular HTML only form.
HTML:
<div ng-controller="myController">
<form id="myForm">
<input ng-model="handle">
<button ng-click="submitForm($event)">Submit</button>
</form>
</div>
Currently I'm doing it like I am below. The problem is, I'm still on the same page, and then I have to redirect. But the next page's content depends on the form submission, and I'd rather not store the contents of the form submission in the session.
angular.module('myApp').controller('myController', ['$scope', function($scope) {
$scope.handle;
$scope.submitForm = function($event) {
$event.preventdefault();
var modifiedHandle= $scope.handle + 'handle';
$http({
url: '/submit',
method: 'POST',
data: {'handle': modifiedHandle }
}).then(function(response){
$window.location.href = '/success';
//The problem of this approach is that the contents of '/success' depends on the form input.
//I'd rather not have to flash the submitted data to a session. Is there a pure AngularJs way to do this?
}, function(data, status){});
}
}]);