Skip to content

Commit 572965d

Browse files
feat(module:result): support standalone component (#8224)
1 parent 186ef60 commit 572965d

8 files changed

Lines changed: 37 additions & 16 deletions

File tree

components/result/doc/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { NzResultModule } from 'ng-zorro-antd/result';
1818

1919
## API
2020

21-
### nz-result
21+
### nz-result:standalone
2222

2323
| Property | Description | Type | Default |
2424
| ------------ | --------------------------------------- | --------------------------------------------------------------------------------- | -------- |

components/result/doc/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { NzResultModule } from 'ng-zorro-antd/result';
1919

2020
## API
2121

22-
### nz-result
22+
### nz-result:standalone
2323

2424
| 属性 | 说明 | 类型 | 默认值 |
2525
| ------------ | -------------------------- | --------------------------------------------------------------------------------- | -------- |

components/result/partial/not-found.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/
272272
/>
273273
</g>
274274
</svg>
275-
`
275+
`,
276+
standalone: true
276277
})
277278
export class NzResultNotFoundComponent {}

components/result/partial/server-error.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/
1010
encapsulation: ViewEncapsulation.None,
1111
selector: 'nz-result-server-error',
1212
exportAs: 'nzResultServerError',
13+
standalone: true,
1314
template: `
1415
<svg width="254" height="294">
1516
<defs>

components/result/partial/unauthorized.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/
1010
encapsulation: ViewEncapsulation.None,
1111
selector: 'nz-result-unauthorized',
1212
exportAs: 'nzResultUnauthorized',
13+
standalone: true,
1314
template: `
1415
<svg width="251" height="294">
1516
<g fill="none" fillRule="evenodd">

components/result/result-cells.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { Directive } from '@angular/core';
1010
exportAs: 'nzResultTitle',
1111
host: {
1212
class: 'ant-result-title'
13-
}
13+
},
14+
standalone: true
1415
})
1516
export class NzResultTitleDirective {}
1617

@@ -19,13 +20,15 @@ export class NzResultTitleDirective {}
1920
exportAs: 'nzResultSubtitle',
2021
host: {
2122
class: 'ant-result-subtitle'
22-
}
23+
},
24+
standalone: true
2325
})
2426
export class NzResultSubtitleDirective {}
2527

2628
@Directive({
2729
selector: 'i[nz-result-icon], div[nz-result-icon]',
28-
exportAs: 'nzResultIcon'
30+
exportAs: 'nzResultIcon',
31+
standalone: true
2932
})
3033
export class NzResultIconDirective {}
3134

@@ -34,7 +37,8 @@ export class NzResultIconDirective {}
3437
exportAs: 'nzResultContent',
3538
host: {
3639
class: 'ant-result-content'
37-
}
40+
},
41+
standalone: true
3842
})
3943
export class NzResultContentDirective {}
4044

@@ -43,6 +47,7 @@ export class NzResultContentDirective {}
4347
exportAs: 'nzResultExtra',
4448
host: {
4549
class: 'ant-result-extra'
46-
}
50+
},
51+
standalone: true
4752
})
4853
export class NzResultExtraDirective {}

components/result/result.component.ts

Lines changed: 20 additions & 1 deletion
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, NgSwitch, NgSwitchCase } from '@angular/common';
78
import {
89
ChangeDetectionStrategy,
910
ChangeDetectorRef,
@@ -19,6 +20,13 @@ import {
1920
import { Subject } from 'rxjs';
2021
import { takeUntil } from 'rxjs/operators';
2122

23+
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
24+
import { NzIconModule } from 'ng-zorro-antd/icon';
25+
26+
import { NzResultNotFoundComponent } from './partial/not-found';
27+
import { NzResultServerErrorComponent } from './partial/server-error.component';
28+
import { NzResultUnauthorizedComponent } from './partial/unauthorized';
29+
2230
export type NzResultIconType = 'success' | 'error' | 'info' | 'warning';
2331
export type NzExceptionStatusType = '404' | '500' | '403';
2432
export type NzResultStatusType = NzExceptionStatusType | NzResultIconType;
@@ -82,7 +90,18 @@ const ExceptionStatus = ['404', '500', '403'];
8290
'[class.ant-result-info]': `nzStatus === 'info'`,
8391
'[class.ant-result-warning]': `nzStatus === 'warning'`,
8492
'[class.ant-result-rtl]': `dir === 'rtl'`
85-
}
93+
},
94+
imports: [
95+
NgIf,
96+
NzOutletModule,
97+
NzIconModule,
98+
NgSwitch,
99+
NzResultNotFoundComponent,
100+
NzResultServerErrorComponent,
101+
NzResultUnauthorizedComponent,
102+
NgSwitchCase
103+
],
104+
standalone: true
86105
})
87106
export class NzResultComponent implements OnChanges, OnDestroy, OnInit {
88107
@Input() nzIcon?: string | TemplateRef<void>;

components/result/result.module.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
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 { CommonModule } from '@angular/common';
86
import { NgModule } from '@angular/core';
97

10-
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
11-
import { NzIconModule } from 'ng-zorro-antd/icon';
12-
138
import { NzResultNotFoundComponent } from './partial/not-found';
149
import { NzResultServerErrorComponent } from './partial/server-error.component';
1510
import { NzResultUnauthorizedComponent } from './partial/unauthorized';
@@ -33,8 +28,7 @@ const cellDirectives = [
3328
];
3429

3530
@NgModule({
36-
imports: [BidiModule, CommonModule, NzOutletModule, NzIconModule],
37-
declarations: [NzResultComponent, ...cellDirectives, ...partial],
31+
imports: [NzResultComponent, ...cellDirectives, ...partial],
3832
exports: [NzResultComponent, ...cellDirectives]
3933
})
4034
export class NzResultModule {}

0 commit comments

Comments
 (0)