Search code examples
angularlayoutabp-frameworkng-zorro-antd

Using ng-zorro-antd UI Components With the ABP Framework


Can we consider the ng-zorro-antd as a replacement for UI components for abp angular?

Links

https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement

https://ng.ant.design/docs/introduce/en


Solution

    1. Add ng-zorro-antd

      yarn add ng-zorro-antd

    2. Add required modules to shared.module.ts

    import { CoreModule } from '@abp/ng.core';
    import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
    import { NgModule } from '@angular/core';
    import { ThemeBasicModule } from '@abp/ng.theme.basic';
    import { ThemeSharedModule } from '@abp/ng.theme.shared';
    import { NgxValidateCoreModule } from '@ngx-validate/core';
    import { NzLayoutModule } from 'ng-zorro-antd/layout'; //add this line
    
    @NgModule({
      declarations: [],
      imports: [
        CoreModule,
        ThemeSharedModule,
        ThemeBasicModule,
        NgbDropdownModule,
        NgxValidateCoreModule,
        NzLayoutModule //add this line
      ],
      exports: [
        CoreModule,
        ThemeSharedModule,
        ThemeBasicModule,
        NgbDropdownModule,
        NgxValidateCoreModule,
        NzLayoutModule //add this line
      ],
      providers: []
    })
    export class SharedModule {}

    1. Follow the instructions from

    https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement#how-to-replace-a-layout

    1. Go to \src\app\my-layout\my-layout.component.html and add the below code.

      <nz-layout>
        <nz-header>Header</nz-header>
        <nz-content>
            <router-outlet></router-outlet>
        </nz-content>
        <nz-footer>Footer</nz-footer>
    </nz-layout>