user3653474
user3653474

Reputation: 3852

Checkbox checked not working based on condition in angular

I have this checkbox when user.IsActive is 0 still the checkbox is checked

<input type="checkbox"  [(ngModel)]="user.IsActive" (change)="user.IsActive = $event.target.checked ? 1: 0" [checked]="user.IsActive == 1 || user.IsActive=='1' ? true : false">

i have used this condition [checked]="user.IsActive == 1 || user.IsActive=='1' ? true : false"

but it's not working.

Any solution Thanks

Upvotes: 0

Views: 131

Answers (1)

Satsangpriyadas Swami
Satsangpriyadas Swami

Reputation: 237

Jay Swaminarayan Try this

<input type="checkbox" (change)="user.IsActive = !user.IsActive" [checked]="user.IsActive">

Upvotes: 1

Related Questions