0

应用程序工作正常使用platform-browser的时候,但在服务器不工作,抛出下面的错误在服务器控制台“找不到主出口”单独的模块app.routing.module.ts角度使用时,平台的服务器,

const routes: Routes = [ 
{ 
    path: '', 
    component: MainComponent, 
    resolve: { 
    categoryLists: CategoriesResolver 
    }, 
    children: [ 
    { path: '', pathMatch: 'full', component: HomeComponent} 
    ] 
    } 
]; 

@NgModule({ 
    imports: [RouterModule.forRoot(routes)], 
    exports: [RouterModule], 
    providers: [CategoriesResolver] 
}) 
export class AppRoutingModule { } 

app.component.html

<div> 
    <router-outlet></router-outlet> 
</div> 

回答

0

如果您使用children属性,则必须拥有2个路由器插座。你有2个吗?为MainComponent开启,为子节点开启。

在你的MainComponent模板中,你也应该有一个路由器插座。

+0

我在'MainComponent'中实际上有'',它可以在'platform-b​​rowser'下正常工作。 –

+0

所以'app.component.html'中有''router-outlet',还有'main.component.html'?有没有可能隐藏它们的'* ngIf'? – trichetriche

+0

是的,确切地说。 不,没有* ngIf。我想知道为什么它不工作**只有平台服务器**。 –