Merge pull request #4 from Julian30520/cecile

version finale branche cecile
This commit is contained in:
Julian 2022-01-11 20:55:52 +01:00 committed by GitHub
commit 3272bd9f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View file

@ -4,7 +4,8 @@
<input class="form-control" <input class="form-control"
type="text" type="text"
placeholder="Recherche ta belle plante" placeholder="Recherche ta belle plante"
aria-label="Input Recherche ta belle plante"> aria-label="Input Recherche ta belle plante"
(input)="onRecherchePlante($event)">
<div class="py-3"> <div class="py-3">
Trier par : Trier par :

View file

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { PlantouneService } from 'src/app/services/plantoune.service'; import { PlantouneService } from 'src/app/services/plantoune.service';
import * as _ from 'underscore'; import * as _ from 'underscore';
import { contains, includes } from 'underscore';
@ -47,12 +48,10 @@ export class PageAccueilComponent implements OnInit {
* plantouneService; * plantouneService;
* *
* constructor(plantouneService: PlantouneService) { * constructor(plantouneService: PlantouneService) {
* this.plantouneService = plantouneService; * this.plantouneService = plantouneService; }
* }
*/ */
ngOnInit(): void { ngOnInit(): void {
this.plantouneService.getData().subscribe( this.plantouneService.getData().subscribe(
@ -81,7 +80,7 @@ export class PageAccueilComponent implements OnInit {
console.log(listUniqJsCategories); console.log(listUniqJsCategories);
this.listCategoriesFilter = listUniqJsCategories; this.listCategoriesFilter = listUniqJsCategories;
this.listData = listPlant; this.listData = [...listPlant];
this.listData.length = 9; this.listData.length = 9;
console.log(this.listData); console.log(this.listData);
@ -93,6 +92,23 @@ export class PageAccueilComponent implements OnInit {
this.plantouneService.plantLiked$.next('') this.plantouneService.plantLiked$.next('')
} }
onRecherchePlante(choix: any) {
const search = choix.target.value
console.log(search);
this.listData = this.listDataGlobal.filter((plant) => {
if(plant.product_name.toLowerCase().includes(search.toLowerCase())){
return plant;
}
});
//Equivaut à la ligne ci-dessous (version abrégée)
//this.listData = this.listDataGlobal.filter((plant) => plant.product_name.toLowerCase().includes(search.toLowerCase()))
console.log(this.listData);
if (this.listData.length >= 9) {this.listData.length=9}
}
}
onListCategory(categoryArray: string[]) { onListCategory(categoryArray: string[]) {
// this.listData=listData; // this.listData=listData;
//console.log(typeof(valueText)); //console.log(typeof(valueText));
@ -204,3 +220,4 @@ onPriceTri() : void {
} }
} }
} }