3
3
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
4
4
*/
5
5
6
- import { PlatformModule } from '@angular/cdk/platform' ;
7
6
import {
8
7
ChangeDetectionStrategy ,
9
8
ChangeDetectorRef ,
@@ -20,16 +19,17 @@ import {
20
19
numberAttribute
21
20
} from '@angular/core' ;
22
21
23
- import { NzConfigKey , NzConfigService , WithConfig } from 'ng-zorro-antd/core/config' ;
22
+ import { NzConfigKey , WithConfig } from 'ng-zorro-antd/core/config' ;
24
23
import { NzShapeSCType , NzSizeLDSType } from 'ng-zorro-antd/core/types' ;
24
+ import { toCssPixel } from 'ng-zorro-antd/core/util' ;
25
25
import { NzIconModule } from 'ng-zorro-antd/icon' ;
26
26
27
27
const NZ_CONFIG_MODULE_NAME : NzConfigKey = 'avatar' ;
28
28
29
29
@Component ( {
30
30
selector : 'nz-avatar' ,
31
31
exportAs : 'nzAvatar' ,
32
- imports : [ NzIconModule , PlatformModule ] ,
32
+ imports : [ NzIconModule ] ,
33
33
template : `
34
34
@if (nzIcon && hasIcon) {
35
35
<nz-icon [nzType]="nzIcon" />
@@ -77,17 +77,15 @@ export class NzAvatarComponent implements OnChanges {
77
77
@ViewChild ( 'textEl' , { static : false } ) textEl ?: ElementRef < HTMLSpanElement > ;
78
78
79
79
private el : HTMLElement = inject ( ElementRef ) . nativeElement ;
80
+ private cdr = inject ( ChangeDetectorRef ) ;
80
81
81
- constructor (
82
- public nzConfigService : NzConfigService ,
83
- private cdr : ChangeDetectorRef
84
- ) {
82
+ constructor ( ) {
85
83
afterRender ( ( ) => this . calcStringSize ( ) ) ;
86
84
}
87
85
88
- imgError ( $ event : Event ) : void {
89
- this . nzError . emit ( $ event) ;
90
- if ( ! $ event. defaultPrevented ) {
86
+ imgError ( event : Event ) : void {
87
+ this . nzError . emit ( event ) ;
88
+ if ( ! event . defaultPrevented ) {
91
89
this . hasSrc = false ;
92
90
this . hasIcon = false ;
93
91
this . hasText = false ;
@@ -128,7 +126,7 @@ export class NzAvatarComponent implements OnChanges {
128
126
129
127
private setSizeStyle ( ) : void {
130
128
if ( typeof this . nzSize === 'number' ) {
131
- this . customSize = ` ${ this . nzSize } px` ;
129
+ this . customSize = toCssPixel ( this . nzSize ) ;
132
130
} else {
133
131
this . customSize = null ;
134
132
}
0 commit comments