1
是否有可能在angular2中的主要组件之前解析服务?主(自举)组件的Angular2解析器?
是否有可能在angular2中的主要组件之前解析服务?主(自举)组件的Angular2解析器?
执行的决心服务下的应用程序的默认
export const appRoutes: Routes = [
{path:'', pathMatch: 'full', redirectTo: 'home'},
{
path: 'home',
component: AppComponent,
resolve: function(){
//your service call
},
{
path: 'path1/:id',
component: YourComponent,
resolve: {
someObject: ComponentResolve
}
}
];
@Injectable()
export class ComponentResolve implements Resolve<Interface> {
constructor(private yourService: YourService) {}
resolve(route: ActivatedRouteSnapshot) {
return this.yourService.getMethod(route.params['id']);
}
那里是我的自举主要成分的路由,'路径:“”'重定向到'道:“家”,成分:“HomeComponent'' ,AppComponent由'@NgModule({..... bootstrap:[AppComponent]'})'引导'' –
你的应用程序的入口点是什么? – Aravind
我使用'platformBrowserDynamic()。bootstrapModule(AppModule);' –