I am working on Angular 5 application. I have reactive form which are all working fine. Now I have requirement to disable input when user click on checkbox true.. all is working fine expect I want to know how to disable input from component. I successfully get id of input but not sure what do next???
component
private handleQuestionAnswerProvidedStateChange(questionAnswerProvidedState:QuestionAnswerProvidedStateDataModel)
{
console.log(">>>>>>> questionAnswerProvidedStateEvent ",questionAnswerProvidedState);
var elementReference = document.getElementById(questionAnswerProvidedState.QuestionId);
console.log("elementReference ",elementReference);
}
template
<div *ngSwitchCase="'textbox'"> <small>textbox</small>
<div class="form-group">
<input *ngSwitchCase="'textbox'"
[formControlName]="question.key"
[id]="question.key"
[type]="question.type"
[(ngModel)]="question.value"
(keyup.enter)="onChangeValue($event, previousValue, responseId, question.key, 'textbox'); previousValue = question.value"
(blur)="onChangeValue($event, previousValue, responseId, question.key, 'textbox'); previousValue = question.value"
(focus)="previousValue=question.value"
>
</div>
</div>
following text is loop, so there will many input each with unique id
ViewChild()for input element in the component file and setdisabled = trueif (document.getElementById("CheckBoxId").checked == true){ document.getElementById("textFieldId").disabled = true; }