Question: Is it possible to retrieve a collection of query string values and assign them to a property of type Filter
in a service component class?
interface Filter{
title?: string;
genreId?: number;
inCinemas?: boolean;
upcomingReleases?: boolean;
}
rather than doing the following tedious, error prone of retrieval and assignment?
constructor(private route: ActivatedRoute) { }
ngOnInit(): void {
this.route.paramMap.subscribe({
next: params => this.title = params.get('title'),
error: e => console.log(e)
});
this.route.paramMap.subscribe({
next: params => this.genreId = params.get('genreId'),
error: e => console.log(e)
});
this.route.paramMap.subscribe({
next: params => this.inCinemas = params.get('inCinemas'),
error: e => console.log(e)
});
this.route.paramMap.subscribe({
next: params => this.UpcomingReleases = params.get('upcomingReleases'),
error: e => console.log(e)
});
}