Reputation: 806
I am new to Nebular theme. I have a checkbox but it's not working.
HTML
<nb-checkbox [value]="checked" (change)="toggle($event)"></nb-checkbox>
TypeScript
toggle(checked: any) {
this.checked = checked.target.checked;
}
Module.ts
//import
import { NbCheckboxModule } from '@nebular/theme';
imports: [NbCheckboxModule]
toggle function is being called fine but checkbox is not being checked.
I have been debugging since a long time but couldn't identify the issue. Any suggestions about what could be wrong? Thank you.
Angular Version: 7.1
Nebular version: ^3.5.0
Upvotes: 1
Views: 7029
Reputation: 1
Add the following in your HTML:
<nb-checkbox status="primary" [value]="checked" (change)="setCheckedStatus($event)">Primary</nb-checkbox>
Add the following in your component.ts file:
checked: true; // declare this variable in your component
setCheckedStatus(checked) {
console.log('checked', checked.target.checked);
this.checked = checked.target.checked; // your variable
}
Upvotes: 0
Reputation: 6609
I think you should use it like in these examples
it works with value
and checked
inputs
<nb-checkbox [checked]="checked" (checkedChange)="toggle($event)">Toggle me</nb-checkbox>
i created stackblitz for you with working example https://stackblitz.com/edit/angular-nb-checkbox?file=src/app/app.component.ts
Upvotes: 2