avancement searchBar
This commit is contained in:
parent
3dcdbfb405
commit
e8a1dcc759
3 changed files with 15 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { ApiBackService } from 'src/app/services/api-back.service';
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -9,37 +9,33 @@ import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
})
|
})
|
||||||
export class SearchBarComponent implements OnInit {
|
export class SearchBarComponent implements OnInit {
|
||||||
|
|
||||||
searchText = new EventEmitter();
|
searchText = new EventEmitter();
|
||||||
listRestau: any [];
|
listRestau: any[];
|
||||||
restauByName : any[];
|
restauByName: any[];
|
||||||
|
|
||||||
constructor(private apiBackService : ApiBackService, private route: Router, private activatedRoute: ActivatedRoute) {
|
constructor(private apiBackService: ApiBackService, private route: Router) {
|
||||||
|
|
||||||
this.listRestau = [];
|
this.listRestau = [];
|
||||||
this.restauByName = [];
|
this.restauByName = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
|
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
|
||||||
this.listRestau = restaurants;
|
this.listRestau = restaurants;
|
||||||
});
|
});
|
||||||
console.log(this.listRestau);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeInput(search :string) {
|
onChangeInput(search: string) {
|
||||||
|
|
||||||
|
|
||||||
// this.searchText.emit(search)
|
|
||||||
this.restauByName = this.listRestau;
|
this.restauByName = this.listRestau;
|
||||||
this.restauByName = this.restauByName.filter((restau : any) =>
|
|
||||||
restau.nom.toLowerCase().includes(search.toLowerCase()));
|
|
||||||
|
|
||||||
|
this.restauByName = this.restauByName.filter((restau: any) =>
|
||||||
|
restau.nom.toLowerCase().includes(search.toLowerCase()));
|
||||||
console.log(this.restauByName);
|
console.log(this.restauByName);
|
||||||
|
|
||||||
this.apiBackService.setListRestau(this.restauByName, "filtres");
|
this.apiBackService.setListRestau(this.restauByName, "filtres");
|
||||||
this.route.navigate(['restaurants']);
|
this.route.navigate(['restaurants']);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,6 @@ export class FiltersPageComponent implements OnInit {
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
console.log(this.activatedRoute.snapshot.routeConfig?.path);
|
|
||||||
console.log(restaus);
|
|
||||||
|
|
||||||
this.apiBackService.setListRestau(restaus, this.activatedRoute.snapshot.routeConfig?.path);
|
this.apiBackService.setListRestau(restaus, this.activatedRoute.snapshot.routeConfig?.path);
|
||||||
// on fait passer en second parametre le path de la route c'est a dire "filtres"
|
// on fait passer en second parametre le path de la route c'est a dire "filtres"
|
||||||
this.route.navigate(['restaurants']);
|
this.route.navigate(['restaurants']);
|
||||||
|
|
|
@ -6,5 +6,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue