From 87824c582463c85d4b40327f66783067fc70613f Mon Sep 17 00:00:00 2001 From: Julian Tomczyk Date: Mon, 10 Jan 2022 17:15:14 +0100 Subject: [PATCH] ajout onRatingFilter --- .../filter-side-bar/filter-side-bar.component.html | 2 +- .../filter-side-bar/filter-side-bar.component.ts | 10 ++++++++-- .../pages/page-accueil/page-accueil.component.html | 2 +- .../pages/page-accueil/page-accueil.component.ts | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 4 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 b09d95f..9423810 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 @@ -36,7 +36,7 @@

Avis

- +
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 c493c5e..e6aa792 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 @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; @Component({ selector: 'app-filter-side-bar', @@ -7,6 +7,8 @@ import { Component, Input, OnInit } from '@angular/core'; }) export class FilterSideBarComponent implements OnInit { @Input() listCategories: string[]; + @Output() stateNumber = new EventEmitter(); + filterStateNumber: number = 0; constructor() { this.listCategories = []; @@ -15,8 +17,12 @@ export class FilterSideBarComponent implements OnInit { ngOnInit(): void { } + onStateNumberChange(stateNumber: number): void { + this.filterStateNumber = stateNumber; + } + onSendRating():void { - console.log("coucou"); + this.stateNumber.emit(this.filterStateNumber); } } diff --git a/src/app/pages/page-accueil/page-accueil.component.html b/src/app/pages/page-accueil/page-accueil.component.html index 50b9406..20de017 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); + } + }); + this.listData = this.listRate; + console.log(this.listData); + } + }