How to disable all the fields in a template driven form in angular How to disable all the fields in a template driven form in angular typescript typescript

How to disable all the fields in a template driven form in angular


As mentioned in the comment you can wrap the form inside a fieldset tag and achieve this as below:

<form>    <fieldset [disabled]="fieldsetDisabled">        <!-- YOUR FIELDS HERE -->    </fieldset></form>

And you can change handle the state in your controller by toggling a local variable and between the disabled/enabled states as:

this.fieldsetDisabled = true;  // Disables the fieldsetthis.fieldsetDisabled = false; // Enables the fieldset