AngularJS:how to disable all the form controls in a form?

angularjs, javascript

Solution

Rather than handling it at per-field level, you can put all form elements into fieldset and use ng-disabled to disable the whole fieldset.

Problem

I want to disable all the form components so that it can't be edited when view button is clicked. this is my form ``` <form action="#" class="form-horizontal" > <div class="form-group"> <label for="fieldname" class="col-md-3 control-label">Name</label> <div class="col-md-6"> <input type="text" ng-model="newItem.customSelected" typeahead="name as name.name for name in members | filter:{name:$viewValue}" class="form-control" /> </div> </div> <div class="form-group"> <label for="fieldhname" class="col-md-3 control-label">House name</label> <div class="col-md-6"> <input type="text" ng-model="newItem.customSelected1" typeahead="house_name as house_name.house_name for house_name in family | filter:{house_name:$viewValue}" class="form-control" /> </div> </div> <div class="form-group"> <label for="" class="col-md-3 control-label"><?php echo $this->lang->line('label_family_id'); ?></label> <div class="col-md-6"> <input type="text" ng-model="newItem.customSelected2" typeahead="fm as fm.family_reg_no for fm in family | filter:{family_reg_no:$viewValue}" class="form-control" /> </div> </div> <div class="col-md-3"></div> </form> ``` and this is my button ``` <input type="button" class="finish btn-success btn" ng-click="view(newItem)" value="view"/> ```

Original source

Related problems