1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| import { NgModule } from '@angular/core';
import { NzAffixModule } from 'ng-zorro-antd/affix'; import { NzAlertModule } from 'ng-zorro-antd/alert'; import { NzAnchorModule } from 'ng-zorro-antd/anchor'; import { NzAutocompleteModule } from 'ng-zorro-antd/auto-complete'; import { NzAvatarModule } from 'ng-zorro-antd/avatar'; import { NzBackTopModule } from 'ng-zorro-antd/back-top'; import { NzBadgeModule } from 'ng-zorro-antd/badge'; import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb'; import { NzButtonModule } from 'ng-zorro-antd/button'; import { NzCalendarModule } from 'ng-zorro-antd/calendar'; import { NzCardModule } from 'ng-zorro-antd/card'; import { NzCarouselModule } from 'ng-zorro-antd/carousel'; import { NzCascaderModule } from 'ng-zorro-antd/cascader'; import { NzCheckboxModule } from 'ng-zorro-antd/checkbox'; import { NzCollapseModule } from 'ng-zorro-antd/collapse'; import { NzCommentModule } from 'ng-zorro-antd/comment'; import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation'; import { NzTransButtonModule } from 'ng-zorro-antd/core/trans-button'; import { NzWaveModule } from 'ng-zorro-antd/core/wave'; import { NzDatePickerModule } from 'ng-zorro-antd/date-picker'; import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; import { NzDividerModule } from 'ng-zorro-antd/divider'; import { NzDrawerModule } from 'ng-zorro-antd/drawer'; import { NzDropDownModule } from 'ng-zorro-antd/dropdown'; import { NzEmptyModule } from 'ng-zorro-antd/empty'; import { NzFormModule } from 'ng-zorro-antd/form'; import { NzGridModule } from 'ng-zorro-antd/grid'; import { NzI18nModule } from 'ng-zorro-antd/i18n'; import { NzIconModule } from 'ng-zorro-antd/icon'; import { NzInputModule } from 'ng-zorro-antd/input'; import { NzInputNumberModule } from 'ng-zorro-antd/input-number'; import { NzLayoutModule } from 'ng-zorro-antd/layout'; import { NzListModule } from 'ng-zorro-antd/list'; import { NzMentionModule } from 'ng-zorro-antd/mention'; import { NzMenuModule } from 'ng-zorro-antd/menu'; import { NzMessageModule } from 'ng-zorro-antd/message'; import { NzModalModule } from 'ng-zorro-antd/modal'; import { NzNotificationModule } from 'ng-zorro-antd/notification'; import { NzPageHeaderModule } from 'ng-zorro-antd/page-header'; import { NzPaginationModule } from 'ng-zorro-antd/pagination'; import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm'; import { NzPopoverModule } from 'ng-zorro-antd/popover'; import { NzProgressModule } from 'ng-zorro-antd/progress'; import { NzRadioModule } from 'ng-zorro-antd/radio'; import { NzRateModule } from 'ng-zorro-antd/rate'; import { NzResultModule } from 'ng-zorro-antd/result'; import { NzSelectModule } from 'ng-zorro-antd/select'; import { NzSkeletonModule } from 'ng-zorro-antd/skeleton'; import { NzSliderModule } from 'ng-zorro-antd/slider'; import { NzSpinModule } from 'ng-zorro-antd/spin'; import { NzStatisticModule } from 'ng-zorro-antd/statistic'; import { NzStepsModule } from 'ng-zorro-antd/steps'; import { NzSwitchModule } from 'ng-zorro-antd/switch'; import { NzTableModule } from 'ng-zorro-antd/table'; import { NzTabsModule } from 'ng-zorro-antd/tabs'; import { NzTagModule } from 'ng-zorro-antd/tag'; import { NzTimePickerModule } from 'ng-zorro-antd/time-picker'; import { NzTimelineModule } from 'ng-zorro-antd/timeline'; import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; import { NzTransferModule } from 'ng-zorro-antd/transfer'; import { NzTreeModule } from 'ng-zorro-antd/tree'; import { NzTreeSelectModule } from 'ng-zorro-antd/tree-select'; import { NzTypographyModule } from 'ng-zorro-antd/typography'; import { NzUploadModule } from 'ng-zorro-antd/upload'; import { NzResizableModule } from 'ng-zorro-antd/resizable'; import { NzPipesModule } from 'ng-zorro-antd/pipes';
@NgModule({ exports: [ NzAffixModule, NzAlertModule, NzAnchorModule, NzAutocompleteModule, NzAvatarModule, NzBackTopModule, NzBadgeModule, NzButtonModule, NzBreadCrumbModule, NzCalendarModule, NzCardModule, NzCarouselModule, NzCascaderModule, NzCheckboxModule, NzCollapseModule, NzCommentModule, NzDatePickerModule, NzDescriptionsModule, NzDividerModule, NzDrawerModule, NzDropDownModule, NzEmptyModule, NzFormModule, NzGridModule, NzI18nModule, NzIconModule, NzInputModule, NzInputNumberModule, NzLayoutModule, NzListModule, NzMentionModule, NzMenuModule, NzMessageModule, NzModalModule, NzNoAnimationModule, NzNotificationModule, NzPageHeaderModule, NzPaginationModule, NzPopconfirmModule, NzPopoverModule, NzProgressModule, NzRadioModule, NzRateModule, NzResultModule, NzSelectModule, NzSkeletonModule, NzSliderModule, NzSpinModule, NzStatisticModule, NzStepsModule, NzSwitchModule, NzTableModule, NzTabsModule, NzTagModule, NzTimePickerModule, NzTimelineModule, NzToolTipModule, NzTransButtonModule, NzTransferModule, NzTreeModule, NzTreeSelectModule, NzTypographyModule, NzUploadModule, NzWaveModule, NzResizableModule, NzPipesModule, ] }) export class NgZorroAntdModule {
} ```
然后在`app.module.ts`引用`NgZorroAntdModule`。在顶部应用ts文件再在`@NgModule` `imports`中添加,修改后的代码如下 ``` TypeScript import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NZ_I18N } from 'ng-zorro-antd/i18n'; import { zh_CN } from 'ng-zorro-antd/i18n'; import { registerLocaleData } from '@angular/common'; import zh from '@angular/common/locales/zh'; import { CarouselComponent } from './modules/carousel/carousel.component'; import { NgZorroAntdModule } from './ng-zorro-antd.module';
registerLocaleData(zh);
@NgModule({ declarations: [ AppComponent, CarouselComponent ], imports: [ BrowserModule, AppRoutingModule, FormsModule, HttpClientModule, BrowserAnimationsModule, NgZorroAntdModule, ], providers: [{ provide: NZ_I18N, useValue: zh_CN }], bootstrap: [AppComponent] }) export class AppModule { }
|