I'm trying to figure how can you filter given products based on the material with a checkbox ? Should i be using pipes ? Should i be using only filter ?
Product-list.HTML
<div class="category-container">
<div class="wrapper">
<h2>Cotton</h2>
<div class="form-check">
<input type="checkbox">
<label for="defaultCheck1" class="form-check-label">
Cotton
</label>
</div>
</div>
</div>
<div class="container">
<div class="row align-items-start">
<div *ngFor="let product of products" class="col-6">
<app-product-card [product]="product" ></app-product-card>
</div>
</div>
</div>
Product-list.component.ts
import { Component, OnInit, Input } from '@angular/core';
import { ProductService } from 'src/app/_services/product.service';
import { Product } from 'src/app/_models/product';
@Component({
selector: 'app-product-list',
templateUrl: './product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent implements OnInit {
@Input() product: Product;
products: Product[];
constructor(private productService: ProductService) { }
ngOnInit() {
this.loadProducts();
}
loadProducts() {
this.productService.getProducts().subscribe((products: Product[]) => {
this.products = products;
}, error => {
console.log(error);
});
}
}