2017-03-09 82 views

回答

-1

执行的决心服务下的应用程序的默认

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']); 
    } 
+0

那里是我的自举主要成分的路由,'路径:“”'重定向到'道:“家”,成分:“HomeComponent'' ,AppComponent由'@NgModule({..... bootstrap:[AppComponent]'})'引导'' –

+0

你的应用程序的入口点是什么? – Aravind

+0

我使用'platformBrowserDynamic()。bootstrapModule(AppModule);' –