0

I have a variable that is either 1 or 0 called {{CurrentItem.STATUS}}

How do I make the checkbox checked/unchecked depending on the value of {{CurrentItem.STATUS}}. 1 = Checked & 2 = Unchecked. I would prefer an Angular solution that doesn't need any javascript/typescript.

Something like this would be perfect:

<input type="checkbox" checked="{{CurrentItem.STATUS}} == 1">

2 Answers 2

2

You can use two-way data binding with ngModel

<input type="checkbox" [(ngModel)]="CurrentItem.STATUS">

This will work as 0 is considered Falsy in JS

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! :) Appreciate your help
0

This works:

<input type="checkbox" [checked]="CurrentItem.STATUS == 1">

2 Comments

Is CurrentItem.STATUS supposed to change when you check/uncheck the checkbox?
Nope not necessary, just for initializing values :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.