Есть ли способ отправить форму с помощью AngularJs без использования асинхронного вызова? Я хотел бы, чтобы он действовал так, как будто я нажал кнопку отправки в обычной форме HTML.AngularJS Form Submit and Redirect
HTML:
<div ng-controller="myController">
<form id="myForm">
<input ng-model="handle">
<button ng-click="submitForm($event)">Submit</button>
</form>
</div>
В настоящее время я делаю это, как я ниже. Проблема в том, что я все еще на одной странице, а затем мне нужно перенаправить. Но содержимое следующей страницы зависит от отправки формы, и я бы предпочел не хранить содержимое представления формы в сеансе.
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){});
}
}]);