How to compare 2 array of objects and when value is matched then checked angular material checkbox? eg: In this case operator
object is matched so checkbox is checked for operator
app.ts
const arr1 = [
{
"id":"1",
"name":"operator"
},
{
"id":"2",
"name":"admins"
}
]
const arr2 = [
{
"id":"1",
"name":"operator"
},
{
"id":"3",
"name":"client"
}
]
this.arr1.forEach(a1Obj => {
this.arr2.some(a2Obj => {
if (a2Obj.id === a1Obj.id) {
console.log(a1Obj);
}
})
});
app.html
<div class="col" *ngFor="let group of groups; let i = index">
<mat-checkbox value="group.id" [labelPosition]="'after'" [checked]="true" (change)="assignGroups($event, group.id)">
</mat-checkbox>
</div>
Aucun commentaire:
Enregistrer un commentaire