Component Replacement
You can replace some ABP components with your custom components.
The reason that you can replace but cannot customize default ABP components is disabling or changing a part of that component can cause problems. So we named those components as Replaceable Components.
How to Replace a Component
Create a new component that you want to use instead of an ABP component. Add that component to declarations
and entryComponents
in the AppModule
.
Then, open the app.component.ts
and execute the add
method of ReplaceableComponentsService
to replace your component with an ABP component as shown below:
How to Replace a Layout
Each ABP theme module has 3 layouts named ApplicationLayoutComponent
, AccountLayoutComponent
, EmptyLayoutComponent
. These layouts can be replaced the same way.
A layout component template should contain
<router-outlet></router-outlet>
element.
The example below describes how to replace the ApplicationLayoutComponent
:
Run the following command to generate a layout in angular
folder:
Add the following code in your layout template (my-application-layout.component.html
) where you want the page to be loaded.
Open app.component.ts
in src/app
folder and modify it as shown below:
If you like to replace a layout component at runtime (e.g: changing the layout by pressing a button), pass the second parameter of the
add
method ofReplaceableComponentsService
as true. DynamicLayoutComponent loads content using a router-outlet. When the second parameter of theadd
method is true, the route will be refreshed, so use it with caution. Your component state will be gone and any initiation logic (including HTTP requests) will be repeated.
Layout Components
How to Replace LogoComponent
Run the following command in angular
folder to create a new component called LogoComponent
.
Open the generated logo.component.ts
in src/app/logo
folder and replace its content with the following:
Open app.component.ts
in src/app
folder and modify it as shown below:
The final UI looks like below:
How to Replace RoutesComponent
Run the following command in angular
folder to create a new component called RoutesComponent
.
Open the generated routes.component.ts
in src/app/routes
folder and replace its content with the following:
Import the SharedModule
to the imports
array of AppModule
:
Open the generated routes.component.html
in src/app/routes
folder and replace its content with the following:
Open app.component.ts
in src/app
folder and modify it as shown below:
The final UI looks like below:
How to Replace NavItemsComponent
Run the following command in angular
folder to create a new component called NavItemsComponent
.
Open the generated nav-items.component.ts
in src/app/nav-items
folder and replace the content with the following:
Import the SharedModule
to the imports
array of AppModule
:
Open the generated nav-items.component.html
in src/app/nav-items
folder and replace the content with the following:
Open app.component.ts
in src/app
folder and modify it as shown below:
The final UI looks like below: