【发布时间】:2020-01-14 15:59:11
【问题描述】:
我正在尝试在复选框的未选中条件上添加边框红色但不起作用。它基于 .ng-touched.ng-invalid 这个类名。如果未从复选框中选择,则应为红色边框。现在该框将变为红色,但我需要复选框边框仅在未选中条件下为红色。怎么做?
https://stackblitz.com/edit/angular-q7aiwj?file=src/app/app.component.html
app.component.html:
<form [formGroup]="form" (ngSubmit)="submit()">
<label formArrayName="orders" *ngFor="let order of form.controls.orders.controls; let i = index">
<input type="checkbox" [formControlName]="i">
{{ordersData[i].name}}
</label>
<div *ngIf="!form.valid">At least one order must be selected</div>
<br>
<button type="submit">submit</button>
</form>
【问题讨论】:
-
HTML 不允许更改复选框的边框颜色,因为您需要使用轮廓或自定义复选框
标签: css angular typescript angular6 angular7