У меня проблема с реализацией распознавателя на моих маршрутах, поскольку у него нет проблем, пока я не InitialDataResolver
в свой модуль маршрутизации.
страницы-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,
children: [
{ path: '', component: HomeComponent },
{ path: 'docs', component: DocsComponent }
],
resolve: {
init: InitialDataResolver
},
}
];
@NgModule({
imports: [ RouterModule.forChild(routes) ],
exports: [ RouterModule ],
providers: [ InitialDataResolver ]
})
export class PagesRoutingModule { }
начально-data.resolver.ts
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observer } from 'rxjs/Observer';
import { AppInitService } from '../services/app-init.service';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class InitialDataResolver implements Resolve<any> {
constructor(private appInitService: AppInitService) {}
resolve(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<any> {
return Observable.create((observer: Observer<any>) => {
this.appInitService.init()
.subscribe(data => {
this.appInitService.preload();
observer.next(data);
observer.complete();
});
});
}
}
Ошибка, с которой я сталкиваюсь, является ERROR Error: "[object Object]"
. см. снимок ниже: