I want to disable text-area based on the option selected from the dropdown values. In my component.ts
file, I have defined a variable to keep a track of if the text area is to be disabled or not
messageDisabled: boolean = false
, and there is a function that triggers on change of dropdown value
getdropdownGender(event) {
const value = event;
if (value == 'a' || value == 'b')
this.messageDisabled = true
else
this.messageDisabled = false
}
The part of my component.html
file is
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Gender</label><span class="asterick">*</span>
<select
type="text"
formControlName="gender"
class="form-control border-primary"
[(ngModel)]="selected_gender"
#t
(change)="getdropdownGender(t.value)"
>
<option value="">Select Gender</option>
<option
value="{{ _position }}"
*ngFor="let _position of genderList"
>
{{ _position }}
</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Message</label>
<textarea
[disabled]="messageDisabled"
cols="30"
rows="3"
type="text"
class="form-control border-primary"
formControlName="message"
placeholder="Message"
>
</textarea>
</div>
</div>
</div>
But the [disabled]
parameter in the text area is not working (based on the condition of messageDisabled
value). Can anyone please help me resolve this issue ?