angularjs - How to reset Bootstrap Form -
here im using bootstrap validations angularjs when form submitted columns reset shows validation..but aim should not display validations
bootstrap
<div class="modal" id="modal1"> <div class="modal-dialog"> <div class="modal-content"> <form name="f1" novalidate ng-submit="save(auth.emp)"> <div class="modal-body"> <div class="form-horizontal"> <div class="form-group"> <div class="row"> <div class="col-sm-4"> email </div> <div class="col-sm-8"> <input type="text" name="email" class="form-control" ng-model="auth.email" ng-class="submitted?'ng-dirty':''" required /> <span class="error" ng-show="(f1.email.$dirty ||submitted) && f1.email.$error.required">email req</span> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-sm-4"> password </div> <div class="col-sm-8"> <input type="text" name="psw" class="form-control" ng-model="auth.password" ng-class="submitted?'ng-dirty':''" required /> <span class="error" ng-show="(f1.psw.$dirty ||submitted) && f1.psw.$error.required">password req</span> </div> </div> </div> </div> </div> <div class="modal-footer"> <input type="submit" value="{{loginaction}}" /> </div> </form> </div> </div> </div>
angularcode.js
$scope.save = function (emp) { if ($scope.loginaction = "login") { $scope.submitted = true; if ($scope.isformvalid == true) { var ss = { email: $scope.auth.email, password: $scope.auth.password, } var xxer = myservices.getlogin(ss); xxer.then(function (msg) { $scope.msg = msg.data; $('#modal2').modal('show') reset(); }) } } }
reset
function reset() { $scope.email = ''; $scope.password = ''; }
i think looking this:
function reset() { $scope.auth.email = '' $scope.auth.password = ''; }
Comments
Post a Comment