1

How can I get checkbox value without using ngModel (cause I don't want to declare field variable for every checkbox)

when code be like :

<input type="checkbox" (click)="foo(bar)">

and

public foo(bar) {
    console.log(bar);
}

Expected output is true or false (whatever that shows checkbox status)

1
  • Both answers bellow are correct Commented Jan 28, 2018 at 18:17

2 Answers 2

2
<input #bar type="checkbox" (click)="foo(bar.checked)">

Demo

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

Comments

2

try this

<input type="checkbox" (change)="foo($event.target.checked)">

Comments

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.