NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.85k stars 3.9k forks source link

Update title of custom modal #6663

Open JEIK08 opened 3 years ago

JEIK08 commented 3 years ago

Reproduction link

Example

Steps to reproduce

Use the NzModalService to create a custom modal, the NzModalRef is injected to the custom modal component, the injected dependency is used to update the modal configurations but the title of the modal (nzTitle) is not being updated.

What is expected?

The title of the modal changes to the new one

What is actually happening?

The title of the modal stay without changes

Environment Info
ng-zorro-antd 11.4.0
Browser Google Chrome
cparkinsonMYCM commented 3 years ago

Experiencing the same here.

If there is no title set initially, I can update the title once with updateConfig But once a title is set it cannot be updated any more...

FrontEndNoah commented 2 years ago

+1

brice-noowu commented 2 years ago

+1

egalley commented 4 months ago

Hello,

Same problem, but solved using a template.

import { Component } from '@angular/core';

@Component({ selector: 'nz-demo-modal-basic', template: ` <button nz-button [nzType]="'primary'" (click)="showModal()">Show Modal <nz-modal [(nzVisible)]="isVisible" [nzTitle]="tplHeader" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> <ng-container *nzModalContent>

Content one

    <p>Content two</p>
    <p>Content three</p>
    <button nz-button nzType="primary" (click)="Title=Title=='Changed' ? 'Title' : 'Changed'">Change Title</button>
  </ng-container>
</nz-modal>
<ng-template #tplHeader>{{Title}}</ng-template>

` }) export class NzDemoModalBasicComponent { isVisible = false; Title = 'First Title';

constructor() {}

showModal(): void { this.isVisible = true; }

handleOk(): void { console.log('Button ok clicked!'); this.isVisible = false; }

handleCancel(): void { console.log('Button cancel clicked!'); this.isVisible = false; } }

StefaniOSApps commented 1 month ago

same