angularjs - hide submit button again after clicking (ng-show - form validation) -
i have following code, shows a.btn anchor if both inputs have values , inputurl valid url. works fine want hide button again on click, how do this, reset form or hide button on click?
<form name="myform" class="row inputs"> <div class="col-xs-5"> <label for="exampleinputpassword1">enter title/description</label> <input name="inputname" type="text" id="urlname" class="form-control" placeholder="" ng-model="mvname" required> </div> <div class="col-xs-5"> <label for="exampleinputpassword1">enter url</label> <input type="url" name="inputurl" id="urllink" class="form-control" placeholder="" ng-model="mvurl" required> </div> <div class="col-xs-2"> <a href="javascript:" ng-click="savetolist($event)" class="btn btn-block post" ng-show="myform.$valid">post</a> </div> </form>
what i've done before create scope variable in controller:
$scope.formsubmitted = false;
then in savetolist function set $scope.formsubmitted true. here have few options. if you're "post" button actual button set disabled attribute. check if formsubmitted true inside savetolist function , if true don't continue. or can change ng-show be:
ng-show="myform.$valid && !formsubmitted"
Comments
Post a Comment