dashboard component is global component. users module is lazy loaded which contains login component. I want to access this dashboard component in the lazy loaded login component. How do I achieve it? I know we can use Shared module. But, I am not sure how to implement it exactly. Please, guide me through.
Dashboard.componenet.html
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<p-menu [model]="menuItems"></p-menu>
</div>
<div class="col-md-9">
</div>
</div>
</div>
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
//PrimeNG
import { MenuModule } from 'primeng/primeng';
//components
import { AppComponent } from './app.component';
import { DashboardComponent } from './dashboard/dashboard.component';
const appRoutes = [
{ path: '', component: DashboardComponent },
{ path: 'users', loadChildren: 'app/users/users.module#UsersModule'}
]
@NgModule({
declarations: [
AppComponent,
DashboardComponent
],
imports: [
BrowserModule,
MenuModule,
RouterModule.forRoot(appRoutes)
],
exports:[DashboardComponent],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
users.module.ts
//Interfaces
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
//Components
import { LoginComponent } from './login/login.component';
const lazyRoutes = [
{path:'login/login', component: LoginComponent}
]
@NgModule({
declarations:[
LoginComponent
// DashboardComponent
],
imports: [
// AppModule,
RouterModule.forChild(lazyRoutes)
],
exports:[],
providers: []
})
export class UsersModule {}
login.component.html
<dashboard></dashboard>[enter image description here][1]
