我需要一个建议,如何为我的应用制作 iteration := 0;
loop
if counter = 1 then
。
我有一个根应用程序和该应用程序内的两个不同项目。
router-outlet
如果我运行app1,它们将通过ROOT APP
|
|---app1
| |
| |-app1.module
| |-app1.routing
| |-app1.component
|
|---app2
| |-app2.module
| |-app2.routing
| |-app2.component
|
|
rootApp.module
rootApp.routing
rootApp.component
我想这样,
rootApp <router-outlet></router-outlet>
还
APP1 -> app1.component (<router-outlet name="app1"></router-outlet>) -> rootApp (<router-outlet></router-outlet>)
这是我的rootApp APP2 -> app2.component (<router-outlet name="app2"></router-outlet>) -> rootApp (<router-outlet></router-outlet>)
rootApp-routing.module
导出:[RouterModule] })
这是我的const routes: Routes = [
{ path: "app1", loadChildren: "../../projects/app1/src/app/app.module#app1" },
{ path: "app2", loadChildren: "../../projects/app2/src/app/app.module#app2" },
{ path: "**", redirectTo: "/app1/one" }
];
@NgModule({
imports: [RouterModule.forRoot(routes), app1.forRoot(),
app2.forRoot(),
app1-route.module
与const routes: Routes = [
{ path: "app1/home", component: HomeComponent, outlet: "app1", canActivate: [AppAuthGuard]
},
{ path: "app1", redirectTo: "app1/home", outlet: "app1", canActivate:
[AppAuthGuard] }
];
app2-route.module
在我的
我总是会出错
main.ts:13错误:路由'app1'的配置无效:没有子级或loadChildren的无组件路由不能设置命名出口
答案 0 :(得分:0)
在app1-route.module
const routes: Routes = [{
path: "home", component: HomeComponent, outlet:"app1", canActivate: [AppAuthGuard]
},
{ path: "", redirectTo: "home", outlet: "app1", canActivate:
[AppAuthGuard] }
];