From 08d05a41d4719c1342bc190f3dc0444a8e0b66f1 Mon Sep 17 00:00:00 2001 From: Julian30520 Date: Tue, 11 Jan 2022 15:58:12 +0100 Subject: [PATCH] parseFloat --- .../filter-side-bar.component.html | 6 ++--- .../filter-side-bar.component.ts | 7 ++++++ .../page-accueil/page-accueil.component.html | 2 +- .../page-accueil/page-accueil.component.ts | 22 +++++++++++++------ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/app/components/filter-side-bar/filter-side-bar.component.html b/src/app/components/filter-side-bar/filter-side-bar.component.html index 9423810..b9d6b88 100644 --- a/src/app/components/filter-side-bar/filter-side-bar.component.html +++ b/src/app/components/filter-side-bar/filter-side-bar.component.html @@ -22,12 +22,12 @@

Prix

- - + +
- Valider +
diff --git a/src/app/components/filter-side-bar/filter-side-bar.component.ts b/src/app/components/filter-side-bar/filter-side-bar.component.ts index e6aa792..d3bb300 100644 --- a/src/app/components/filter-side-bar/filter-side-bar.component.ts +++ b/src/app/components/filter-side-bar/filter-side-bar.component.ts @@ -8,6 +8,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; export class FilterSideBarComponent implements OnInit { @Input() listCategories: string[]; @Output() stateNumber = new EventEmitter(); + @Output() rangeNumber = new EventEmitter(); filterStateNumber: number = 0; constructor() { @@ -25,4 +26,10 @@ export class FilterSideBarComponent implements OnInit { this.stateNumber.emit(this.filterStateNumber); } + onSendValues(minNum: any, maxNum: any): void { + let rangeArray: number[] = [parseFloat(minNum.value), parseFloat(maxNum.value)]; + console.log(typeof(rangeArray[0])); + this.rangeNumber.emit(rangeArray); + } + } diff --git a/src/app/pages/page-accueil/page-accueil.component.html b/src/app/pages/page-accueil/page-accueil.component.html index 20de017..ce25eb3 100644 --- a/src/app/pages/page-accueil/page-accueil.component.html +++ b/src/app/pages/page-accueil/page-accueil.component.html @@ -1,5 +1,5 @@
- +
{ if(product.product_rating >= stateNumber) { - this.listRate.push(product); + listRate.push(product); } }); - console.log(this.listRate); - this.listData = [...this.listRate]; + this.listData = [...listRate]; + if(this.listData.length >= 9) this.listData.length = 9; + } + + onPriceFilter(rangeNumber: number[]) { + console.log(rangeNumber); + let listRangedProduct: any[] = []; + this.listDataGlobal.forEach(product => { + if(parseFloat(product.product_unitprice_ati) >= rangeNumber[0] && parseFloat(product.product_unitprice_ati) <= rangeNumber[1]) { + listRangedProduct.push(product); + } + }); + this.listData = [...listRangedProduct]; if(this.listData.length >= 9) this.listData.length = 9; }