Consider the following route configuration:
const routes: Routes = [
{
path: \'\',
component: AppComponent,
resolve: {
app: AppResolver
You can try something like this:
constructor(private activatedRoute: ActivatedRoute) {
this.activatedRoute.parent.data.subscribe(data => {
this.profile = data.profile;
});
}
updateProfile(newProfile) {
(this.activatedRoute.parent.data as BehaviorSubject<any>).next({profile: newProfile});
}
I've tested the solution 'runGuardsAndResolvers', it works for my use case, the resolver is called at each sub-page changes.
It is only adding this option the part of your routes that you want behave this way.
export const ROUTES: any = [
{
path: 'project/:name',
runGuardsAndResolvers: "always",
component: ProjectComponent,
resolve: { project: ProjectResolver },
children: [
...
There is a parameter you can use in your route configuration called 'runGuardsAndResolvers' that will affect when the resolver runs. In this case you would want to set it to 'always'. This means that the resolver will run any time the child routes of that route change. See the route documentation for more information.
By above way i can call the resolver. But it not change data which comes from my backend server so i got one solution i call my service method again in success part and got new changed data from backend server.