How to disable the required validation check for most of the form

I have most of the form that should be disabled in some scenarios. I use a tag <fieldset>with an attribute ng-disabledto enable / disable part of the form.

 <ng-form name="myForm">
    <fieldset ng-disabled="myModel.isFieldsetDisabled">
      <input id="myTextField" type="text" ng-required="true" ng-model="myModel.myAttribute">
      ... lots of other fields
    </fieldset>
  </ng-form>

Problem : when I turn off <fieldset>, the ng form is still invalid because some of the input fields are empty (but must be required). I expected these checks to be disabled when disabled.

How to achieve the correct ng-form without errors with all ng-all attributes in all input fields in the disabled form.

see plunker: https://plnkr.co/edit/2JpSFqBqwdfgTa2wO4Ei?p=preview

+4
1

- :

ng-required="!myModel.isFieldsetDisabled"

i.e: , myModel.isFieldsetDisabled ...

+3

All Articles