angular-resolver

resolver on lazy loading angular

喜夏-厌秋 提交于 2021-02-18 22:49:17
问题 is there a way to add a resolver before loading a lazy load module? i tried to add resolve to the routs configuration but it is not triggered, also didn't find any thing useful about it on the web. any help would be appreciated import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; // services import {SecondResolverService} from "./second.resolver.service"; const routes: Routes = [ { path: 'first' , loadChildren: './first/first.module#FirstModule' },

How to return HttpClient response body from a request?

两盒软妹~` 提交于 2021-01-28 05:06:48
问题 I have a component that relies on an API response for its content. I have set up the resolver but it still returns before my data is ready. How can I make my pull_categories() function wait until the response body is received and then return? Rather than returning an empty object because it won't wait or even call it in my case below. service.ts private _categories = []; constructor(private http: HttpClient) { } pull_categories() { this.http.post('https://myapi.com/something', null)

Resolver does not resolve if another data stream is added

痴心易碎 提交于 2020-06-23 08:33:30
问题 I am trying to use a resolver in order to retrieve data depending on the given parameters the route holds. Unfortunately, the moment I add another data stream that my data depends on the resolver never actually resolves. If I directly return an immediately resolving value everything works fine. I debugged the situation to see that I receive all partial information but it just fails to actually resolve in the end. Here's a quick sample. Hit me up if there's more code needed to understand the

CanActivate guards on child routes run before parent Resolve finish

放肆的年华 提交于 2020-01-13 09:06:59
问题 I'm trying to resolve data before navigating to children routes as i have to use that data in children guard. The issue is parent resolver, resolves data after the child guard is fired. Resolver takes long time to resolve data // app.module.ts const appRoutes: Routes = [ { path: 'login', component: LoginComponent }, { path: '', component: SiteLayoutComponent, children: [ { path: '', redirectTo: 'warehouse', pathMatch: 'full' }, { path: 'warehouse', loadChildren: './warehouse/warehouse.module

Router Resolver not rendering component

折月煮酒 提交于 2019-12-22 07:06:00
问题 I have this router resolver to retrieve data from the Google Firestore. I am trying to use the Resolver to fetch the data ahead. When I place debugger at resolve function it shows me the data retrieved from the Server. But it is never returning from the resolve() method. Can anyone please help me out. Routing Module const routes: Routes = [ { path: '', component: HomeComponent}, { path: 'projects', component: ProjectsComponent, resolve: {projectData: ProjectResolver} }, { path: 'about',

Create a Routes path that loads a specific component based on condition

荒凉一梦 提交于 2019-12-11 14:59:15
问题 I want to load distinct components for similar structured paths. Means : example.com/whatever-post-slug --> Load Post Component example.com/whatever-page-slug --> Load Page Component example.com/hello-i-am-a-string --> Load Post Component (because that slug belongs to a post) example.com/about-us --> Load Page Component (because that slug belongs to a page) Why would I do this? One may think : hey but why don't you just define two prefixed different paths, which is what paths are there for?

Angular6 Synchronously Load Route Data

有些话、适合烂在心里 提交于 2019-12-11 04:37:17
问题 Okay, I recently implemented SSR into my Angular6 application, with the intention of rendering dynamic HTML in a crawlable manner. All seems to be working fine, but my issue is rendering data from an API endpoint. As soon as a user arrives on my site, a list of top posts that have been retrieved from a Node server will be displayed. In order to retrieve the data before page load, I implemented a resolver for my posts service. The resolver will resolve an Observable, which will then be

Resolver Emitting Error ` ERROR Error: “[object Object]” `

一曲冷凌霜 提交于 2019-11-30 06:01:12
I'm having a problem with regards of implementing a resolver on my routes as it has no issue until I include InitialDataResolver on my routing module. pages-routing.module.ts import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { FrontComponent } from '../layouts/front/front.component'; import { HomeComponent } from './home/home.component'; import { DocsComponent } from './docs/docs.component'; import { InitialDataResolver } from './../shared/resolvers/initial-data.resolver'; const routes: Routes = [ { path: '', component: FrontComponent,

Why would you use a resolver with Angular

北城余情 提交于 2019-11-29 22:55:18
I like the idea of resolver s. You can say that: - for a given route you expect some data to be loaded first - you can just have a really simple component with no observable (as retrieving data from this.route.snapshot.data ) So resolvers makes a lot of sense. BUT: - You're not changing the URL and displaying your requested component until you receive the actual response. So you can't (simply) show the user that something is happening by rendering your component and showing as much as you can (just like it's advised to, for the shell app with PWA). Which means that when having a bad connection