Here is my HTML form:
<form class="form-login" name="loginForm" novalidate ng-submit="login()">
<fieldset>
<h2>Login</h2>
<input type="text" required class="input-block-level" placeholder="Username" ng-model="username" name="username" tabindex="1" xs-input-sync>
<input type="password" required class="input-block-level" placeholder="Password" ng-model="password" name="password" tabindex="2" xs-input-sync>
</fieldset>
</form>
and here's the controller method called when submitting the form:
$scope.login = function() {
$http.post($scope.serviceUrls.getAuthenticationUrl($scope.username), {
"password": $scope.password
}).success(function(data, status, headers) {
}).error(function(data, status) {
});
return false;
}
Everything works fine up to this point. But since the browser only shows the native "Remember Password" dialog only if you have the action="/" attribute set on the form, I've also added it on my form.
After adding the action="/" the form gets submitted when hitting the Enter key or the Login button no matter what I try. I've also tried to add the $event parameter to the html login function call, and then do $event.preventDefault(); but still no go.
The same thing happens on urls like:
<a class="xs-btn edit-btn" ng-click="toggleEditMode($event)"></a>
I've tried: $event.preventDefault();, return false;, adding href="", href="#". But none of the work and I always get redirected to the root of the site. The only one that works is href="javascript:void(0);".
Any idea of what I'm doing wrong? It seems like something is wrong app wide.
As I see, just adding onsubmit="return false" to <form> do the job: http://plnkr.co/edit/a7bUU1VWAZOUYyXQjvF3?p=preview