From b52ad50e509559349da31fb8ae332464647ed6a0 Mon Sep 17 00:00:00 2001 From: Laffery <49607541+Laffery@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:45:49 +0800 Subject: [PATCH] docs: fix some errors in ssr (#8506) --- components/form/demo/register.ts | 4 ++-- components/icon/page/index.ts | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/components/form/demo/register.ts b/components/form/demo/register.ts index defbb1f197..d776bb6204 100644 --- a/components/form/demo/register.ts +++ b/components/form/demo/register.ts @@ -136,11 +136,11 @@ import { NzFormTooltipIcon } from 'ng-zorro-antd/form'; max-width: 600px; } - .phone-select { + .ant-select.ant-select-in-form-item.phone-select { width: 70px; } - .register-are { + .register-area { margin-bottom: 8px; } ` diff --git a/components/icon/page/index.ts b/components/icon/page/index.ts index 8af6cbff9c..9ca2bbe327 100644 --- a/components/icon/page/index.ts +++ b/components/icon/page/index.ts @@ -3,8 +3,18 @@ * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ -import { DOCUMENT } from '@angular/common'; -import { Component, Inject, Input, OnDestroy, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core'; +import { DOCUMENT, isPlatformBrowser } from '@angular/common'; +import { + Component, + Inject, + Input, + OnDestroy, + OnInit, + PLATFORM_ID, + TemplateRef, + ViewChild, + ViewContainerRef +} from '@angular/core'; import { of, Subscription } from 'rxjs'; import { manifest, ThemeType } from '@ant-design/icons-angular'; @@ -661,8 +671,10 @@ export class NzPageDemoIconComponent implements OnInit, OnDestroy { } constructor( - // eslint-disable-next-line @typescript-eslint/no-explicit-any + /* eslint-disable @typescript-eslint/no-explicit-any */ @Inject(DOCUMENT) private dom: any, + @Inject(PLATFORM_ID) private platformId: any, + /* eslint-enable @typescript-eslint/no-explicit-any */ private _iconService: NzIconService, private message: NzMessageService, private viewContainerRef: ViewContainerRef @@ -673,8 +685,11 @@ export class NzPageDemoIconComponent implements OnInit, OnDestroy { ngOnInit(): void { this.setIconsShouldBeDisplayed('outline'); - this.loadModel(); - this.popoverVisible = !localStorage.getItem('disableIconTip'); + // load model in browser + if (isPlatformBrowser(this.platformId)) { + this.loadModel(); + this.popoverVisible = !localStorage.getItem('disableIconTip'); + } } ngOnDestroy(): void {