Skip to content

Commit 3d1427f

Browse files
feat(module:badge): support standalone component (#8201)
* feat(module:badge): support standalone component * feat(module:badge): support standalone component
1 parent 03cda21 commit 3d1427f

6 files changed

Lines changed: 18 additions & 13 deletions

File tree

‎components/badge/badge-sup.component.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6+
import { NgFor, NgIf } from '@angular/common';
67
import {
78
ChangeDetectionStrategy,
89
Component,
@@ -15,6 +16,7 @@ import {
1516
} from '@angular/core';
1617

1718
import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
19+
import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
1820
import { NzSafeAny, NzSizeDSType } from 'ng-zorro-antd/core/types';
1921

2022
@Component({
@@ -24,6 +26,8 @@ import { NzSafeAny, NzSizeDSType } from 'ng-zorro-antd/core/types';
2426
encapsulation: ViewEncapsulation.None,
2527
changeDetection: ChangeDetectionStrategy.OnPush,
2628
animations: [zoomBadgeMotion],
29+
standalone: true,
30+
imports: [NgFor, NgIf, NzNoAnimationModule],
2731
template: `
2832
<ng-container *ngIf="count <= nzOverflowCount; else overflowTemplate">
2933
<span

‎components/badge/badge.component.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { Direction, Directionality } from '@angular/cdk/bidi';
7+
import { NgIf, NgStyle } from '@angular/common';
78
import {
89
ChangeDetectionStrategy,
910
ChangeDetectorRef,
@@ -26,9 +27,11 @@ import { takeUntil } from 'rxjs/operators';
2627
import { zoomBadgeMotion } from 'ng-zorro-antd/core/animation';
2728
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
2829
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
30+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
2931
import { BooleanInput, NzSafeAny, NzSizeDSType } from 'ng-zorro-antd/core/types';
3032
import { InputBoolean } from 'ng-zorro-antd/core/util';
3133

34+
import { NzBadgeSupComponent } from './badge-sup.component';
3235
import { badgePresetColors } from './preset-colors';
3336
import { NzBadgeStatusType } from './types';
3437

@@ -41,6 +44,8 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'badge';
4144
encapsulation: ViewEncapsulation.None,
4245
changeDetection: ChangeDetectionStrategy.OnPush,
4346
animations: [zoomBadgeMotion],
47+
standalone: true,
48+
imports: [NgIf, NgStyle, NzBadgeSupComponent, NzOutletModule],
4449
template: `
4550
<ng-container *ngIf="nzStatus || nzColor">
4651
<span

‎components/badge/badge.module.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,13 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6-
import { BidiModule } from '@angular/cdk/bidi';
7-
import { ObserversModule } from '@angular/cdk/observers';
8-
import { CommonModule } from '@angular/common';
96
import { NgModule } from '@angular/core';
107

11-
import { NzNoAnimationModule } from 'ng-zorro-antd/core/no-animation';
12-
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
13-
14-
import { NzBadgeSupComponent } from './badge-sup.component';
158
import { NzBadgeComponent } from './badge.component';
169
import { NzRibbonComponent } from './ribbon.component';
1710

1811
@NgModule({
19-
declarations: [NzBadgeComponent, NzBadgeSupComponent, NzRibbonComponent],
2012
exports: [NzBadgeComponent, NzRibbonComponent],
21-
imports: [BidiModule, CommonModule, ObserversModule, NzOutletModule, NzNoAnimationModule]
13+
imports: [NzBadgeComponent, NzRibbonComponent]
2214
})
2315
export class NzBadgeModule {}

‎components/badge/doc/index.en-US.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { NzBadgeModule } from 'ng-zorro-antd/badge';
2727
<nz-badge [nzCount]="5" nzStandalone></nz-badge>
2828
```
2929

30-
### nz-badge
30+
### nz-badge:standalone
3131

3232
| Property | Description | Type | Default | Global Config |
3333
| -------- | ----------- | ---- | ------- | ------------- |
@@ -45,7 +45,7 @@ import { NzBadgeModule } from 'ng-zorro-antd/badge';
4545
| `[nzOffset]` | set offset of the badge dot, like[x, y] (Only Non-standalone) | `[number, number]` | - |
4646

4747

48-
### nz-ribbon
48+
### nz-ribbon:standalone
4949

5050
| Property | Description | Type | Default |
5151
| --- | --- | --- | --- |

‎components/badge/doc/index.zh-CN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { NzBadgeModule } from 'ng-zorro-antd/badge';
2828
<nz-badge [nzCount]="5" nzStandalone></nz-badge>
2929
```
3030

31-
### nz-badge
31+
### nz-badge:standalone
3232

3333
| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
3434
| --- | --- | --- | --- | --- |
@@ -46,7 +46,7 @@ import { NzBadgeModule } from 'ng-zorro-antd/badge';
4646
| `[nzOffset]` | 设置状态点的位置偏移,格式为 [x, y] (非独立使用时) | `[number, number]` | - |
4747

4848

49-
### nz-ribbon
49+
### nz-ribbon:standalone
5050

5151
| 参数 | 说明 | 类型 | 默认值 |
5252
| --- | --- | --- | --- |

‎components/badge/ribbon.component.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
ViewEncapsulation
1414
} from '@angular/core';
1515

16+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
17+
1618
import { badgePresetColors } from './preset-colors';
1719

1820
@Component({
@@ -21,6 +23,8 @@ import { badgePresetColors } from './preset-colors';
2123
preserveWhitespaces: false,
2224
encapsulation: ViewEncapsulation.None,
2325
changeDetection: ChangeDetectionStrategy.OnPush,
26+
standalone: true,
27+
imports: [NzOutletModule],
2428
template: `
2529
<ng-content></ng-content>
2630
<div

0 commit comments

Comments
 (0)