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。我想知道爲什麼它不工作**只有平臺服務器**。 –