lundi 15 janvier 2018

A5 + Angular Material event checkboxes filter data

I'm getting data from a json array and creating a checkbox for each of them. I need to filter data by sending in an existing URI (POST) the checked data in an array like the following:

{
    "CategoriesId": [1,3]
}

Products.component.ts

ngOnInit() {
    this.getCategories();
}

getCategories() { code...}

export class ProductsComponent implements OnInit {
public categories: Categories[];
 constructor(private _categoriesservice: CategoriesService){
}

onChangeCategories(event) {
...
  }

Products.component.html

<div *ngIf="categories">
  <hr class="style1">
   <div class="filter-items-phone" *ngFor="let category of categories; let c = index">
     <mat-checkbox (change)="onChangeCategories($event)"></mat-checkbox>
   </div>
</div>




Aucun commentaire:

Enregistrer un commentaire