Questions tagged resolver

Explore the latest questions and answers asked by our top developers.

How to properly use resolver to pass a string for menu in angular

First time using resolver. My resolver looks like this: export class StringResolver implements Resolve<string> { constructor(private data: DataService) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<string> { return‘string’); } } and I am trying to use the data returned as a menu text in routing module like so: { path: ”, component: HomeComponent, data: { menu: […]

Routes are not consumed by SSR server when using Resolvers

I’ve switch my Angular app to server side rendering. This is the function that consumes my route in the server side (server.ts file): //server.ts export function app() { // … const universalRenderer = async (req, res) => { const defaultLang = ‘fr’; res.cookie(‘LOCALIZE_DEFAULT_LANGUAGE’, defaultLang); return consumeRoute(req, res, indexHtml, redisClient, cacheKey); }; server.get(‘*’, universalRenderer, ); return […]

angular component wait for another component to render DOM (resolve)

I have a page that call two component through selector: <app-category-list> <article-view></article-view> In order to gathering datas for article-view I use a resolve attached to the route.module in this way: {path: ‘article-view/:id’, component: ArticleViewComponent , resolve: { article: ArticleDataResolver }, data: {title: ‘View Article’}}, this resolve call a service with a promise inside that does […]

By madenGlitch
Categorized as angular, promise, render, resolve, resolver Tagged , , , ,

How to refresh resolver data in Angular without navigate?

I get data from backend with Resolver. That’s ok. But how can I refresh these data on same route? For example: I have a settings page. User edit some data, then save. After that, I would like refresh data from backend. How can I "trigger" resolver, to call a new HTTP request without Router navigate? […]

By mullern
Categorized as angular, http, resolver Tagged , ,

Observable never completes in Resolver

I am trying to implement a resolver so that my API data is resolved before loading a component. The observable returned from my HTTP request in my service is never completing, causing routing to hang. I have scoured tutorials and Angular documentation to see what I am doing wrong. Any ideas? I have generalized some […]

By Paul Thorsen
Categorized as angular, observable, resolver Tagged , ,

In Angular 10: can I refresh data from Resolver of parent route?

I have a parent route which uses a Resolver to get data. I have several children of this route. The child Components subscribe to this data in their ngOnInit() methods. ngOnInit() { .subscribe((data: { collection: DataCollection }) => { this.collection = data.collection; }); } The Resolver only runs on the first access of one […]

By blogofsongs
Categorized as angular, refresh, reload, resolver, state Tagged , , , ,

Error handling in route resolver with NgRx

I am using resolver to fetch data before the route loads. I am using NgRx effects to call API and set the state. Here’s my resolver code: resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<any> | Promise<any> | any { p = some number return‘quesList’).pipe( take(1), map(queList => { return queList.pageData[p]; }), switchMap(list => { […]

By Priya Verma
Categorized as angular, angular-resolver, ngrx, resolver Tagged , , ,

How to combine data returned by a resolver into a combineLatest call?

I have a resolver on a page to load the data. This resolver returns an Observable<Product[]> Then I combine the stream from the resolver with another stream using combineLatest. But the problem is when I combine the streams, I get an error that says my streams are used before being initialized. I tried to put […]

By andr marquis
Categorized as angular, observable, resolver, rxjs Tagged , , ,

Angular: Iterate over nested object using resolver

I have this resolver service for my admin module: constructor(private userservice: UserService) { } resolve( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable<any> { return this.userservice.getUserById(route.paramMap.get(‘id’)); } } The fethed data in a detail component export class AdminDetailComponent implements OnInit { user: any; constructor(private route: ActivatedRoute) {} ngOnInit() { => { this.user=Array.of(data); console.log(this.user) }); } } […]

By Mellville
Categorized as angular, render, resolver Tagged , ,

Angular resolve only if user is authorised

I want the resolver to only go through if the user is authorised. I have manager and standard level access. The JWT token has a role claim which then says if the user is a "Manager" or "Standard" account. If I log in as manager I get no problems, which is expected. When I log […]

By GolfBravo
Categorized as angular, angular-resolver, resolver Tagged , ,
1 2

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us