Angular:新模块->新路由器出口

时间:2019-08-04 19:44:42

标签: angular

在标准的角度项目上是index.html,其中包含<app-root></app-root>。然后,app.component.html包含<app-header></app-header><router-outlet></router-outlet>

当我现在创建一个带有组件的新模块时:

ng generate module accounts --routing    
ng generate component accounts/app    
    #contains the page-specific content (like a form, text, ...)    
ng generate component accounts/header    
    #contains the header    
ng generate component accounts/main    
    #contains the typical html-layout and `<app-header></app-header><router-outlet name="aux"></router-outlet>`    

如何找到类似index.html的类似入口点?是main.component还是app.component使用不正确?

编辑:

accounts-routing.module:

const routes: Routes = [
 { path: '', component: AppComponent},
 { path: 'app', component: AppComponent },
];

app-routing.module.ts:

const routes: Routes = [
  {
    path: 'accounts', 
    loadChildren: () => import('./accounts/accounts.module').then(mod => mod.AccountsModule)
  }
];

它在app-routing.module.ts而不是account / main ?!上下文中显示AppComponent的内容!

0 个答案:

没有答案