简体   繁体   English

我有一组对象要检查,主要是真的只有一次在复选框上,否则显示警报

[英]I have a array of objects to check from that primary is true is only one time on the checkbox otherwise show alert

I have a array of objects to check from that primary is true is only one time on the checkbox otherwise show alert see image below:-我有一组对象要检查,主要是真的只有一次在复选框上,否则显示警报见下图:-

主要不检查第二次检查

 <mat-checkbox class="example-margin" [(ngModel)]="primary" formControlName="primary"> Make this primary </mat-checkbox>

In this array of object there are 2 primary = true in that在这个 object 数组中,有 2 个 primary = true

Suppose your array is data .假设您的数组是data

let primaryGuys = data.filter(person => person.primary === true);
if(primaryGuys >1) {
   alert('HEY!')
}

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

相关问题 如果复选框被选中,我如何使用平均堆栈中的复选框更新我的待办事项状态,它在 mongodb 数据库中为真,否则为假 - How i can update my todo status using checkbox in mean stack if check box is checked it place true in mongodb database otherwise false 仅在ngModel的值为true时选中此复选框 - Only check the checkbox if the value of ngModel is true mat-checkbox仅在条件为真时检查 - mat-checkbox check only if condition is true 如何使用 *ngIf 仅显示具有相同值的数组的 1 个时间项? - How can I show with *ngIf only 1 time items of array that have the same value? 如何一次只显示一个 *ngIf=“show[i]” - How do I show only one *ngIf=“show[i]” at a time 角2,* ng对于复选框仅选中一个 - angular 2, *ngFor checkbox check only one 如何从带有复选框的阵列中仅检索一个 object? - How can I retrieve only one object from an array with check boxes? primeng - 一次只选择一个复选框项 - primeng - Select only one checkbox item at a time 复选框警报控制器 - 显示图像 - Checkbox Alert Controller - Show image 如何检查我推入对象的对象数组是否具有来自另一个对象数组的特定键值 - How to check if an array of objects where I push into objects has a specific key value from another array of objects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM