Welcome to my DetailService.ts:
Send Detail()
sendDetail(id: number) {
console.log("Sending detail");
const url = this.rootUrl + 'api/Details/Select?ID=' + id;
this.http.get(url).pipe(
retry (3)
).toPromise()
.then((data: any) => {
this.detailSubject.next(data.Entity);
});
}
GetDetail()
getDetail() {
console.log("Getting detail");
console.log(this.detailSubject);
return this.detailSubject;
}
Now let's look at Resolver.ts:
Resolver.ts
resolve(route:ActivatedRouteSnapshot, state:RouterStateSnapshot): Observable<any> {
return this.DetailService.getDetail()
.pipe(
map(object =>
{
console.log(object); //Data retrieved successfully
return object;
})
);
}
Routing to Child Component:
{
path: 'edit/:state',
component: DetailComponent,
data: {
text: 'edit',
nav: true,
breadcrumbs: true
},
resolve: {
object: Resolver
},
canActivate: [AuthGuard]
},
providers: [ Resolver, DetailService ]
Routing to Parent Module:
{
path: 'detailsModule',
loadChildren: 'app/layout/Details/some-
details/some-details.module#SomeDetailsModule',
data: {
preload: false,
text: 'trans Amendment'
},
canActivate: [AuthGuard]
},
Issue: There seems to be an issue with navigation to the component. Upon tracing, it appears that ResolveEnd is not triggered. Here is how I am calling the service within the component:
ngOnInit() {
console.log("Object from Route");
console.log(this.route.snapshot.data['object']);
this.object = this.route.snapshot.data['object'];
}
If you have any insights on where I might be going wrong, please feel free to share. Thank you!