Reputation: 117
Using jQuery I can do something like this:
$('#submitButton').on('click', function(event) {
event.preventDefault();
var result = confirm('Are you sure?');
if (result) {
$('#submitForm').submit();
}
});
Before submit I need confirmation from user and then post data to server with reload (redirect) page. In what way can I do this in Angular?
Upvotes: 0
Views: 191
Reputation: 117
Thanks for suggestions. In this case solution can be:
$scope.submitMyForm = function() {
var result = confirm('Are you sure?');
if (result) {
var finishForm = document.getElementById('finishForm');
finishForm.setAttribute("action", "/some-url");
finishForm.submit();
}
}
Upvotes: 1
Reputation: 121
In angular you are not supposed to submit forms that way, you are supposed to have model variables and use them with $http in order to interact with your server via asynchronous calls, however, angular.js uses jquery and even includes a lite version of it, so, if you must send your form in the traditional way, you can still do so via jquery.
Upvotes: 1