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)
<input #bar type="checkbox" (click)="foo(bar.checked)">
尝试这个
<input type="checkbox" (change)="foo($event.target.checked)">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.