Home > front end >  How to disable or readonly select input angular
How to disable or readonly select input angular

Time:02-10

If the cardSelect variable is true, just let [readonly]="cardSelect"

<select name="card-exp-month" #validateMonth formControlName="digiMes"  name="validade" id="validade"   >
<option value="">Mês</option>
<option value="01">01 Jan</option>
<option value="02">02 Fev</option>
<option value="03">03 Mar</option>
<option value="04">04 Abr</option>
<option value="05">05 Mai</option>
<option value="06">06 Jun</option>
<option value="07">07 Jul</option>
<option value="08">08 Ago</option>
<option value="09">09 Set</option>
<option value="10">10 Out</option>
<option value="11">11 Nov</option>
<option value="12">12 Dez</option>
</select>

When is input text its works

<label for="nomeimpresso">Nome <b>impresso</b> no cartão<span > * 
</span></label>
<input #nomeImpresso formControlName="digiNome"  name="holder-name" id="nomeimpresso" 
 type="text"  [readonly]="cardSelect" >

CodePudding user response:

For disabling the whole "select" element you can :

  <select … [disabled]="isSelectDisabled()">
  …
  </select>

and decide in your controller the logic behind the isSelectDisabled method.

CodePudding user response:

try [disabled]="cardSelect" or if that didn't work [attr.disabled]="!editable ? '' : null" as a workaround.

  • Related