Skip to content

Commit

Permalink
I adjusted the pagination, taking the state of the location of the fo…
Browse files Browse the repository at this point in the history
…rm page
  • Loading branch information
aline-borges committed Oct 19, 2020
1 parent 21010bc commit a0772e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/app/components/form/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ export class FormComponent implements OnInit {
this.typeSearchOption = event;
}

goToHotels(hotels: Array<any>, page: number) {
goToHotels(hotels: Array<any>, page: number, pagination: any, quantity: string, place: string, location: string) {
this.router.navigateByUrl('/hotels', {
state: { hotels: this.hotels, page: this.currentPage }
state: {
hotels: this.hotels,
page: this.currentPage,
pagination: this.pagination,
quantity: this.quantity,
place: this.place,
location: this.location
}
});
}

Expand All @@ -69,7 +76,7 @@ export class FormComponent implements OnInit {
this.currentPage = page;

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToHotels(this.hotels, this.currentPage)
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place, this.location)
})

this.quantity;
Expand Down
8 changes: 5 additions & 3 deletions src/app/components/hotel/hotel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Router } from '@angular/router';
import { HurbService } from '../../service/hurb.service';
import { HeaderComponent } from './../header/header.component';


@Component({
selector: 'app-hotel',
templateUrl: './hotel.component.html',
Expand Down Expand Up @@ -37,8 +36,11 @@ export class HotelComponent implements OnInit {
constructor(private hurbService: HurbService, private router: Router, private titleService: Title){
const nav = this.router.getCurrentNavigation();
this.hotels = nav.extras.state.hotels;

this.currentPage = nav.extras.state.page;
this.pagination = nav.extras.state.pagination;
this.quantity = nav.extras.state.quantity;
this.place = nav.extras.state.place;
this.location = nav.extras.state.place;
}

getLocation(evento: KeyboardEvent, value: string){
Expand Down Expand Up @@ -177,7 +179,7 @@ export class HotelComponent implements OnInit {
this.value = (<HTMLInputElement>document.getElementById('range')).value;
}

ngOnInit():void {
ngOnInit():void {
}

}

0 comments on commit a0772e3

Please sign in to comment.