karansys
karansys

Reputation: 2719

Angular checkbox not visible using mat-checkbox

I tried to display checkbox inside 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.enter image description here

Upvotes: 0

Views: 5889

Answers (1)

Nick Henry
Nick Henry

Reputation: 58

The style is applied to the label because the label is inside of the mat-checkbox tag. 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.

Upvotes: 1

Related Questions