I am using Angular Resolver
to prefetch data from the server before showing the route so a page is not loaded empty, we're Ok about this principle.
My question now is how to use the same Resolver
to prefetch data from server without a route ? To explain more my question here is sketch of my screen :
On the HeadreComponent of my app I need to make some api-call to get person.firstName
and person.lastName
but the header has no defined routes because it's supposed to be shown on the first page (http:localhost:4200\home).
So I'm not able to use the regular syntax in routes config to call the Resolver like this :
{path: 'home', component: HomeComponent, resolve: {personInfos: PersonInfoResolver}}
I might be missing something seen that I'm starting Angular development so be kind please :D
The solution I used it what @trichetriche proposed in comment : using a parent component that has a route () to implement the resolvers and then use @Input()
to pass the data to ChildComponent.