[英]Not able to click nb-checkbox of Nebular theme angular
我是星云主题的新手。 我有一个复选框,但它不起作用。
HTML
<nb-checkbox [value]="checked" (change)="toggle($event)"></nb-checkbox>
TypeScript
toggle(checked: any) {
this.checked = checked.target.checked;
}
模块.ts
//import
import { NbCheckboxModule } from '@nebular/theme';
imports: [NbCheckboxModule]
切换 function 被正常调用,但未选中复选框。
我一直在调试很长时间,但无法确定问题所在。 关于可能出什么问题的任何建议? 谢谢你。
Angular 版本:7.1
星云版本:^3.5.0
我认为您应该像在这些示例中一样使用它
它适用于value
和checked
输入
<nb-checkbox [checked]="checked" (checkedChange)="toggle($event)">Toggle me</nb-checkbox>
我使用工作示例https://stackblitz.com/edit/angular-nb-checkbox?file=src/app/app.component.ts 为您创建了 stackblitz
在 HTML 中添加以下内容:
<nb-checkbox status="primary" [value]="checked" (change)="setCheckedStatus($event)">Primary</nb-checkbox>
在您的 component.ts 文件中添加以下内容:
checked: true; // declare this variable in your component
setCheckedStatus(checked) {
console.log('checked', checked.target.checked);
this.checked = checked.target.checked; // your variable
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.