Topic: checkbox
rtchrisdev pro asked 5 years ago
It is possible to check and un-check a "checkbox" from type script. I see the [checked]="true" option, but I cannot modify the check box. ex [checked]="status" TS -this.status = false . I am trying to create a toggle effect between two check boxes, and then clear the checkbox after the form is saved. Similar to how the radio button will toggle , but the radio button is not working within a table. ex <td></td> . Any thoughts. Thanks
Damian Gemza staff answered 5 years ago
Dear @rtchrisdev
Please try to use the @ViewChild decorator with the CheckboxComponent class. In some method please set the checked property of CheckboxComponent class to true or false (to check or uncheck).
Please take a look at my example code which works fine:
@ViewChild(CheckboxComponent) checkbox: CheckboxComponent;
check() {
this.checkbox.checked = !this.checkbox.checked;
}
<mdb-checkbox #checkbox>Material unchecked</mdb-checkbox>
<button mdbBtn color="primary" (click)="check()">Check</button>
Best Regards,
Damian
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: 7.0.0
- Device: Mac
- Browser: Chrome
- OS: Mac OS
- Provided sample code: No
- Provided link: No