ajout listDataGlobal

This commit is contained in:
Julian30520 2022-01-11 10:26:24 +01:00
parent f883a03581
commit ea2fe72b13

View File

@ -9,11 +9,13 @@ import * as _ from 'underscore';
}) })
export class PageAccueilComponent implements OnInit { export class PageAccueilComponent implements OnInit {
public listData: any[]; public listData: any[];
public listDataGlobal: any[];
public listRate: any[]; public listRate: any[];
public listCategoriesFilter: string[]; public listCategoriesFilter: string[];
constructor(private plantouneService: PlantouneService) { constructor(private plantouneService: PlantouneService) {
this.listData = []; this.listData = [];
this.listDataGlobal = [];
this.listRate = []; this.listRate = [];
this.listCategoriesFilter = []; this.listCategoriesFilter = [];
} }
@ -35,6 +37,8 @@ export class PageAccueilComponent implements OnInit {
this.plantouneService.getData().subscribe( this.plantouneService.getData().subscribe(
(listPlant: any[]) => { (listPlant: any[]) => {
console.log(listPlant); console.log(listPlant);
this.listDataGlobal = [...listPlant];
console.log(this.listDataGlobal);
/** /**
* Technique avec Underscore JS pour recupérer les catégories uniques de nos plantes * Technique avec Underscore JS pour recupérer les catégories uniques de nos plantes
@ -68,7 +72,7 @@ export class PageAccueilComponent implements OnInit {
onRatingFilter(stateNumber: number): void { onRatingFilter(stateNumber: number): void {
console.log(stateNumber); console.log(stateNumber);
this.listRate = []; this.listRate = [];
this.listData.forEach(product => { this.listDataGlobal.forEach(product => {
if(product.product_rating >= stateNumber) { if(product.product_rating >= stateNumber) {
this.listRate.push(product); this.listRate.push(product);
} }