javascript - Hide form on submit with Angular JS -
trying wrap head around angular items , working thru tutorial edit , learn.
clicking below button shows below form. how reverse once form submitted? meaning hiding form on submit until button clicked once more.
<button ng-click="addnewclicked=!addnewclicked;" class="btn btn-sm btn-primary"> <i class="fa fa-plus"></i>add task </button>
basically, form appears, enter , submit, form dissapear upon submit? thinking ng-hide, can using angular? or need javascript/css?
<div id="addform" class="margin-full-5"> <form ng-init="addnewclicked=false; " ng-if="addnewclicked" id="newtaskform" class="add-task"> <div class="form-actions"> <div class="input-group"> <input type="text" class="form-control" name="comment" ng-model="taskinput" placeholder="add new task" ng-focus="addnewclicked"> <div class="input-group-btn"> <button class="btn btn-default" type="submit" ng-click="addtask(taskinput)"> <i class="fa fa-plus"></i> add task </button> </div> </div> </div> </form>
somewhere in view.
<button ng-click="showtheform = !showtheform">add task</button> <form ng-show="showtheform" ng-submit="processform()"> <button>submit</button> <button type="button" ng-click="showtheform = false">cancel</button> </form>
somewhere in controller
$scope.processform = function() { // execute $scope.showtheform = false; }
Comments
Post a Comment