Estou com problema na paginação. Meu código está de acordo com o que foi passado na aula e mesmo assim a paginação não funciona. Está retornando todos as fotos mesmo com a paginação definida. Photo.service.ts
import { HttpClient, HttpParams } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Photo } from "../photo/photo";
const API = "http://localhost:3000";
@Injectable({ providedIn: "root" })
export class PhotoService {
constructor(private http: HttpClient) {}
listFromUsers(userName: string) {
return this.http.get<Photo[]>(API + "/" + userName + "/photos");
}
listFromUserPaginated(userName: string, page: number) {
const params = new HttpParams().append("page", page.toString());
return this.http.get<Photo[]>(API + "/" + userName + "/photos", {
params: params
});
}
}
photo-list.resolver.ts
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import {Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from "@angular/router";
import { PhotoService } from "./../services/photo.service";
import { Photo } from "./../photo/photo";
@Injectable({ providedIn: "root" })
export class PhotoListResolver implements Resolve<Observable<Photo[]>>
{
constructor(private service: PhotoService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Photo[]> {
const userName = route.params.userName;
return this.service.listFromUserPaginated(userName, 1);
}
}