Skip to content

Commit 03cda21

Browse files
feat(module:anchor): support standalone component (#8185)
* feat(module:anchor): support standalone component * feat(module:anchor): support standalone component * feat(module:anchor): support standalone component
1 parent 69dd31a commit 03cda21

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

components/anchor/anchor-link.component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { Platform } from '@angular/cdk/platform';
7+
import { NgIf } from '@angular/common';
78
import {
89
ChangeDetectionStrategy,
910
Component,
@@ -26,6 +27,8 @@ import { NzAnchorComponent } from './anchor.component';
2627
selector: 'nz-link',
2728
exportAs: 'nzLink',
2829
preserveWhitespaces: false,
30+
standalone: true,
31+
imports: [NgIf],
2932
template: `
3033
<a
3134
#linkTitle

components/anchor/anchor.component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
7-
import { DOCUMENT } from '@angular/common';
7+
import { DOCUMENT, NgClass, NgIf, NgStyle, NgTemplateOutlet } from '@angular/common';
88
import {
99
AfterViewInit,
1010
ChangeDetectionStrategy,
@@ -26,6 +26,7 @@ import {
2626
import { fromEvent, Subject } from 'rxjs';
2727
import { takeUntil, throttleTime } from 'rxjs/operators';
2828

29+
import { NzAffixModule } from 'ng-zorro-antd/affix';
2930
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
3031
import { NzScrollService } from 'ng-zorro-antd/core/services';
3132
import { BooleanInput, NgStyleInterface, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
@@ -48,6 +49,8 @@ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: t
4849
selector: 'nz-anchor',
4950
exportAs: 'nzAnchor',
5051
preserveWhitespaces: false,
52+
standalone: true,
53+
imports: [NgClass, NgIf, NgStyle, NgTemplateOutlet, NzAffixModule],
5154
template: `
5255
<nz-affix *ngIf="nzAffix; else content" [nzOffsetTop]="nzOffsetTop" [nzTarget]="container">
5356
<ng-template [ngTemplateOutlet]="content"></ng-template>

components/anchor/anchor.module.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,19 +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 { PlatformModule } from '@angular/cdk/platform';
8-
import { CommonModule } from '@angular/common';
96
import { NgModule } from '@angular/core';
107

11-
import { NzAffixModule } from 'ng-zorro-antd/affix';
12-
138
import { NzAnchorLinkComponent } from './anchor-link.component';
149
import { NzAnchorComponent } from './anchor.component';
1510

1611
@NgModule({
17-
declarations: [NzAnchorComponent, NzAnchorLinkComponent],
1812
exports: [NzAnchorComponent, NzAnchorLinkComponent],
19-
imports: [BidiModule, CommonModule, NzAffixModule, PlatformModule]
13+
imports: [NzAnchorComponent, NzAnchorLinkComponent]
2014
})
2115
export class NzAnchorModule {}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';
1717

1818
## API
1919

20-
### nz-anchor
20+
### nz-anchor:standalone
2121

2222
| Property | Description | Type | Default | Global Config |
2323
| -------- | ----------- | ---- | ------- | ------------- |
@@ -32,7 +32,7 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';
3232
| `(nzChange)` | Listening for anchor link change | `EventEmitter<string>` | - | |
3333
| `(nzScroll)` | The scroll function that is triggered when scrolling to an anchor. | `EventEmitter<NzAnchorLinkComponent>` | - |
3434

35-
### nz-link
35+
### nz-link:standalone
3636

3737
| Property | Description | Type | Default |
3838
| -------- | ----------- | ---- | ------- |

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';
1919

2020
## API
2121

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

2424
| 成员 | 说明 | 类型 | 默认值 | 全局配置 |
2525
| --- | --- | --- | --- | --- |
@@ -34,7 +34,7 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor';
3434
| `(nzChange)` | 监听锚点链接改变 | `EventEmitter<string>` | - | |
3535
| `(nzScroll)` | 滚动至某锚点时触发 | `EventEmitter<NzAnchorLinkComponent>` | - |
3636

37-
### nz-link
37+
### nz-link:standalone
3838

3939
| 成员 | 说明 | 类型 | 默认值 |
4040
| --- | --- | --- | --- |

0 commit comments

Comments
 (0)