O
O
Oleg Morev2019-07-02 11:16:51
Angular
Oleg Morev, 2019-07-02 11:16:51

Angular 7 how to add input checkbox class?

Hello, I have something like this structure:

<div class="switch" [ngClass]=""></div>
<input type="checkbox" [checked]="func">

How can I add a class to the switch if the server's input is false?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-07-02
@Xuxicheta

<div [class.checked]="myCheckbox.checked">bla bla</div>
<input #myCheckbox type="checkbox" (change)="onChange()">

well also there should be an empty method
the method is necessary for start of detection of changes. You need to start this process in some way, you may not need it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question