my project folder structure like below
|-- app
|-- home
|-- home-page
|--home-page.component.css
|--home-page.component.html
|--home-page.component.spec.ts
|--home-page.component.ts
|-- login
|--home-page.component.css
|--home-page.component.html
|--home-page.component.spec.ts
|--home-page.component.ts
|-- user-profile
|--user-profile.component.css
|--user-profile.component.html
|--user-profile.component.spec.ts
|--user-profile.component.ts
|-- home-routing.module.ts
|-- home.module.spec.ts
|-- home.module.ts
|-- app-routing.module.ts
|-- app.component.css
|-- app.component.html
|-- app.component.ts
|-- app.module.ts
my home-routing.module.ts consisting like below
export const HomeRoutingModule: Routes = [
{
path: "user-profile",
children: [
{
path: "user-profile",
component:UserProfileComponent ,
data: {
title: "user-profile",
urls: [{ title: "user-profile", url: "user-profile" }]
}
}
]
}
];
and app-routing.module.ts is like below
{ path: "home", component: LoginComponent },
{
path: "user-profile",
component: HomePageComponent,
children: [
{ path: "user-profile", loadChildren: "./home/home.module#HomeModule" },
]
}
now I'm trying to render user-profile.components.html inside the home-page.component.htmlfor that i tried to add the sample code snippet in the home-page.component.ts like below
<p>this is header</p>
<router-outlet></router-outlet>
<p>this is footer</p>
my url is like below localhost:4200/#/user-profile, but it is rendering only below output except content
this is header
this is footer
I think something I missed, Even I'm not able to figure out that . Could any one point out, whats went wrong in this code .
Edit: home.module.ts
import { NgModule } from '@angular/core';
import { CommonModule, } from '@angular/common';
import { RouterModule } from '@angular/router';
import { HomeRoutingModule } from './home-routing.module';
import { LoginComponent } from './login/login.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import { HomePageComponent } from './home-page/home-page.component';
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(HomeRoutingModule),
HomeRoutingModule,
],
declarations: [UserProfileComponent, HomePageComponent]
})
export class HomeModule { }