8 - Layout Lib and BehaviorSubjects
In this section we make a reusable Layout and a BehaviorSubject to share User state
1. Add a new Layout lib and container component
nx generate @nrwl/angular:lib layoutnx generate @nrwl/angular:component containers/layout --project=layout2. Add the MaterialModule and Router Module to the LayoutModule and export the Layout Component out of the module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LayoutComponent } from './containers/layout/layout.component';
import { MaterialModule } from '@demo-app/material'; // Added
import { RouterModule } from '@angular/router'; // Added
@NgModule({
imports: [CommonModule, MaterialModule, RouterModule], // Added
declarations: [LayoutComponent],
exports: [LayoutComponent]
})
export class LayoutModule {}3. Add a material tool bar to the layout component
3. Add a BehaviourSubject to Auth service
4. Add the LayoutComponent logic to select the current logged in user
6. Add the new component to the Customer Portal apps main view
7. Add styles to styles.scss and layout.scss
8. Add the Layout Module to the AppModule
9. Add a material tool bar logic
Extras
1. Convert Layout component into a pure container component
Last updated