简体   繁体   English

使用 mat-checkbox 看不到角度复选框

[英]Angular checkbox not visible using mat-checkbox

I tried to display checkbox inside angular UI我试图在 Angular UI 中显示复选框

<mat-checkbox [(ngModel)] = "item.role" [checked]="false"> 
  <label>IT Admin</label> 
</mat-checkbox>

I have attached image below and if I tried to create style for mat-checkbox the style is applied including label.我在下面附上了图片,如果我尝试为 mat-checkbox 创建样式,则会应用样式,包括标签。 在此处输入图片说明

The style is applied to the label because the label is inside of the mat-checkbox tag.该样式应用于标签,因为标签位于 mat-checkbox 标签内。 Try separating them and using a form group if you can.如果可以,请尝试将它们分开并使用表单组。

<div class="form-group"> <label for="role">IT Admin</label> <mat-checkbox id="role" [(ngModel)]="item.role" [checked]="item.role"></mat-checkbox> </div>

This is under the assumption that you are using forms.这是在您使用表单的假设下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM