Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] modal support use directive to define the footer #3035

Closed
hsuanxyz opened this issue Mar 6, 2019 · 1 comment · Fixed by #3036
Closed

[Feature] modal support use directive to define the footer #3035

hsuanxyz opened this issue Mar 6, 2019 · 1 comment · Fixed by #3036
Assignees

Comments

@hsuanxyz
Copy link
Member

hsuanxyz commented Mar 6, 2019

What problem does this feature solve?

What does the proposed API look like?

In Template

<nz-modal>
  <p>Content one</p>
  <p>Content two</p>
  <p>Content three</p>
  <div *nzModalFooter>
    <span>Modal Footer: </span>
    <button nz-button nzType="default" (click)="handleCancel()">Custom Callback</button>
    <button nz-button nzType="primary" (click)="handleOk()" [nzLoading]="isConfirmLoading">Custom Submit</button>
  </div>
</nz-modal>

In nzContent component

createComponentModal(): void {
  const modal = this.modalService.create({
    nzTitle: 'Modal Title',
    nzContent: NzModalCustomComponent
  });
}
// ---

@Component({
  selector: 'nz-modal-custom-component',
  template: `
   <div>
     <p>Content one</p>
     <p>Content two</p>
     <p>Content three</p>
   </div>
   <div *nzModalFooter>
     <span>Modal Footer: </span>
     <button nz-button nzType="default" (click)="destroyModal()">Custom Callback</button>
   </div>
  `
})
export class NzModalCustomComponent {

  constructor(private modal: NzModalRef) { }

  destroyModal(): void {
    this.modal.destroy({ data: 'this the result data' });
  }
}
@levitatejay
Copy link

levitatejay commented Jun 24, 2019

I'm trying to make a self contained modal component but having some issues... I'm currently doing the following in MyModalComponent:

# HTML
<ng-template #modalFooter>
   <button (click)="clickHandler()"> ...
</ng-template>

# TS
@ViewChild('modalFooter') public footerTemplate: TemplateRef<any>;

ngOnInit() {
   this.modal.getInstance().nzTitle = 'My Title';
   this.modal.getInstance().nzFooter = this.footerTemplate;
}

But this is causing the modal open animation to be janky because the header and footer aren't rendered until after the animation starts.

If I put this.modal.getInstance().nzFooter = this.footerTemplate; in the constructor instead of NgOnInit then the animation is smooth but the template onClick bindings aren't connected

Is there a better solution for this?

hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Jul 1, 2019
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Jul 17, 2019
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Jul 19, 2019
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Jul 19, 2019
wzhudev pushed a commit that referenced this issue Jul 19, 2019
* feat(module:modal): support use directive to define the footer

close #3035

* docs(module:modal): add custom footer demo

* test(module:modal): add test

* test(module:modal): add test

* fix(module:modal): fix type

* test(module:modal): fix test

* chore: rebase master

* chore: rebase master

* test(module:modal): fix test

* test(module:modal): fix test
Ricbet pushed a commit to Ricbet/ng-zorro-antd that referenced this issue Apr 9, 2020
…RRO#3036)

* feat(module:modal): support use directive to define the footer

close NG-ZORRO#3035

* docs(module:modal): add custom footer demo

* test(module:modal): add test

* test(module:modal): add test

* fix(module:modal): fix type

* test(module:modal): fix test

* chore: rebase master

* chore: rebase master

* test(module:modal): fix test

* test(module:modal): fix test
hsuanxyz added a commit to hsuanxyz/ng-zorro-antd that referenced this issue Aug 5, 2020
…RRO#3036)

* feat(module:modal): support use directive to define the footer

close NG-ZORRO#3035

* docs(module:modal): add custom footer demo

* test(module:modal): add test

* test(module:modal): add test

* fix(module:modal): fix type

* test(module:modal): fix test

* chore: rebase master

* chore: rebase master

* test(module:modal): fix test

* test(module:modal): fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants