I'm using Angular 6. When i want to use route parameters, I use this code:
this.route.params.subscribe(params => {
// use params now as a object variable
});
But I need to use parameters in service calling. Example I have a service for getting user info. And I call this service inside of resolver. If I want to use subscribe, I can not return service result:
resolve(route: ActivatedRouteSnapshot,state: RouterStateSnapshot): Observable<any> {
this.route.params.subscribe(params => {
return this.FixturesService.getFixtures(params);
});
});
It's not working now. It says:
A function whose declared type in neither 'void' nor 'any' must return a value.
How can I return service result, inside of the resolve function with passing route parameters to the service that I called and return it to component?