I\'d like to do a traditional form submit from within a controller. The scenario is that I want to hit a route on my web server and redirect to its response, which I can do
Did you try to use the ng-submit directive on your form? You may return true/false after your validation.
Controller
app.controller('MainCtrl', ['$location', function($scope, $location) {
$scope.submit = function(user) {
var isvalid = true;
// validation
if (isvalid) {
$http.get('api/check_something', {}).then(function(result) {
$location.path(result.data);
});
return true;
}
return false; //failed
}
});
Html (you must not have an action attribute)