Skip to content

Commit

Permalink
refactor(module:anchor): implement new code flow (#8291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoss54 authored Dec 17, 2023
1 parent 0416653 commit 06c9cbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions components/anchor/anchor-link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Platform } from '@angular/cdk/platform';
import { NgIf } from '@angular/common';
import { NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -28,7 +28,7 @@ import { NzAnchorComponent } from './anchor.component';
exportAs: 'nzLink',
preserveWhitespaces: false,
standalone: true,
imports: [NgIf],
imports: [NgTemplateOutlet],
template: `
<a
#linkTitle
Expand All @@ -38,7 +38,11 @@ import { NzAnchorComponent } from './anchor.component';
[target]="nzTarget"
(click)="goToClick($event)"
>
<span *ngIf="titleStr; else titleTpl || nzTemplate">{{ titleStr }}</span>
@if (titleStr) {
<span>{{ titleStr }}</span>
} @else {
<ng-template [ngTemplateOutlet]="titleTpl || nzTemplate" />
}
</a>
<ng-content></ng-content>
`,
Expand Down
9 changes: 7 additions & 2 deletions components/anchor/anchor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: t
standalone: true,
imports: [NgClass, NgIf, NgStyle, NgTemplateOutlet, NzAffixModule],
template: `
<nz-affix *ngIf="nzAffix; else content" [nzOffsetTop]="nzOffsetTop" [nzTarget]="container">
@if (nzAffix) {
<nz-affix [nzOffsetTop]="nzOffsetTop" [nzTarget]="container">
<ng-template [ngTemplateOutlet]="content"></ng-template>
</nz-affix>
} @else {
<ng-template [ngTemplateOutlet]="content"></ng-template>
</nz-affix>
}
<ng-template #content>
<div class="ant-anchor-wrapper" [ngStyle]="wrapperStyle">
<div class="ant-anchor" [ngClass]="{ 'ant-anchor-fixed': !nzAffix && !nzShowInkInFixed }">
Expand Down

0 comments on commit 06c9cbd

Please sign in to comment.