깊은 자식 경로가있는 경로를 만들었습니다. NgModule에 래핑 <router-outlet>
한 AdminComponent 구성 요소에 추가 했습니다 . 하지만 페이지를 새로 고친 후이 오류가 발생했습니다.
'router-outlet' is not a known element
admin.module.ts로 일부 모듈을 가져 오는 것을 잊었 기 때문에 발생했을 수 있습니다.
도와주세요. 감사.
app.routes.ts
export const routes: Routes = [
{
path: '',
component: AppComponent,
children: [
{
path: '',
component: LoginComponent
},
{
path: 'admin',
component: AdminComponent
},
{
path: 'user',
component: UserComponent
},
{
path: 'there',
component: ThereComponent
}
]
}
]
app.module.ts
@NgModule({
imports: [
BrowserModule,
AppRoutes,
FormsModule,
ReactiveFormsModule,
HttpModule,
RouterModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (http: Http) => {
return new TranslateStaticLoader(http, './src/assets/i18n', '.json')
},
deps: [Http]
}),
UserComponentModule,
AdminComponentModule,
LoginComponentModule,
ThereComponentModule,
DashboardComponentModule
],
declarations: [
AppComponent
],
providers: [
FormBuilder
],
bootstrap: [AppComponent]
})
admin.component.ts 및 admin.module.ts
// admin.component.ts
import {Component} from "@angular/core";
@Component({
selector: 'admin',
template: "<router-outlet></router-outlet>",
})
export class AdminComponent {
constructor() {
}
}
// admin.module.ts
const ADMIN_DECLARATION = [
AdminComponent
];
@NgModule({
imports: [
BrowserModule,
TranslateModule,
FormsModule,
ReactiveFormsModule
],
declarations: [
ADMIN_DECLARATION
],
exports: [
ADMIN_DECLARATION
],
providers: [
TranslateService,
FormBuilder
]
})
export class AdminComponentModule {
}
;