By default the input fields are disabled, I should be enable the fields once the check box is checked. Any idea in angular 4 ?
-
2Can you share what you have done?Farasi78– Farasi782018-04-25 18:59:18 +00:00Commented Apr 25, 2018 at 18:59
-
Bind the checked property of checkbox and disabled property of input to a componentProperty[defaults to false], so when checkbox is checked componentProperty will become true which will enable input if you use !componentProperty with input's disabled propertyfaizan– faizan2018-04-25 19:14:41 +00:00Commented Apr 25, 2018 at 19:14
-
@faizan any example references ?Ramana– Ramana2018-04-25 20:09:53 +00:00Commented Apr 25, 2018 at 20:09
Add a comment
|
1 Answer
Not sure if I understand the question here but make sure your check box is not bind a model which is already set to false (or default bool)
If you are simply trying to enable the check box when the checkbox is checked, you can do the following:
export class AppComponent {
isDisabled = true;
triggerSomeEvent() {
this.isDisabled = !this.isDisabled;
return;
}
}
and your HTML:
<input type="checkbox" name="myChk" id="myChk" (change)="triggerSomeEvent()" />
<input type="text" name="myTxt" id="myTxt" value="" [disabled]="isDisabled" />