5

How to disable all the controls in a template driven form.

Tried Solutions.

using filedset and set [disabled] to that - which will not work in IE 9+. Also using fieldset, the inputs are not disabled

 <button class="icon-btn pull-right addNewBtn" type="button" title="Add New " data-toggle="modal" id="Btn" data-backdrop="false"><i (click)="Person(Code)" class="fa fa-user-plus"></i></button>

  <p-radioButton name="type" value="I" label="Inc" [(ngModel)]="type"></p-radioButton>

I don't have a form group, so that solution also didn't work here.

Let me know Is there any other solution in AngularJS 2

derkoe
  • 5,649
  • 2
  • 23
  • 31
user630209
  • 1,123
  • 4
  • 42
  • 93
  • Which absolutly works in ie 11+, cant verify below ie11 but the usage is also only at 0,1% of all browsers. If it realy still is a problem for you, here are some workaurounds https://stackoverflow.com/questions/24119329/fieldset-and-disabling-all-child-inputs-work-around-for-ie – Doomenik Sep 21 '17 at 11:03
  • even with fieldset radio buttons are not disabled, any fix for this "? – user630209 Sep 25 '17 at 05:18

1 Answers1

0

You will need to make sure that each of your inputs understands what "disabled" means for it. Some html elements having the disabled property - like a regular html button - will react to [disabled]="condition". But for your own elements - like p-radioButton - you would need to set a certain "disabled" styling, and prevent parts of your p-radioButton (for example a surrounding div) from forwarding events which should not be forwarded if it's disabled. Then you can use ngClass and set the disabled property to every input where the disabling condition is true.

seawave_23
  • 1,169
  • 2
  • 12
  • 23