I am submitting a angular form using ng-submit. This is the code which I am working on.
<form class="awesome-form" id="loginForm" name="loginForm" ng-submit="submit();" novalidate>
<div class="input-group">
<input id="loginEmailAddress" name="loginEmailAddress"
ng-model="login.loginId"
ng-pattern="/^[_a-zA-Z0-9]+(\.[_a-zA-Z0-9]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4})$/"
ng-keyup = "checkType($event,'login-label');"
required="" type="text" autocomplete="on">
<label id="login-label">Email</label>
</div>
<span class="icon-close" ng-show="!loginForm.loginEmailAddress.$error.required"
ng-click="clear()"></span>
</div>
/*some other form elements come here*/
<button class="login-button-blue"
ng-disabled="!(loginForm.loginEmailAddress.$valid && loginForm.loginPassword.$valid)" type="submit">SIGN IN</button>
</form>
The submit method is calling a service which in turn sends a http post request.
$scope.submit = function() {
SampleService.sampleMethod(angular.toJson(request)).then(function(successData){
/**do something**/
}
}
The sampleservice is as follows:
app.service('SampleService', ['$http', '$q', function ($http, $q) {
this.sampleMethod= function (request) {
var deferred = $q.defer();
$http.post("url", request).success(function (data, status, headers, config) {
deferred.resolve(data);
}).error(function (data, status, headers, config) {
deferred.reject(data);
});
return deferred.promise;
};
}]);
After successful submission of my form, I expect the browser's native autocomplete feature to work. The email address is to be autocompleted when I type in the next time.
It works successful in firefox, but not in chrome. I tried several methods mentioned in other stack overflow questions. But the solutions proved useless.
(Trigger autocomplete without submitting a form)
A fiddle has been given in the solution for that question that it worked in all the browsers(http://jsfiddle.net/6cve0z98/). But it was also not working for me.
- I am using chrome version 41.0.2272.118.
- A post method is used.
Is it a problem with the browser itself or am I doing something wrong? Help me with the solution. Thanks in advance.