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

It cannot close modal when I change a router #447

Closed
fuybooo opened this issue Oct 17, 2017 · 3 comments
Closed

It cannot close modal when I change a router #447

fuybooo opened this issue Oct 17, 2017 · 3 comments

Comments

@fuybooo
Copy link

fuybooo commented Oct 17, 2017

I'm submitting a...


[ x] Bug report  
[ x] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Support request => Please do not submit support request here

Current behavior

step 1: open https://ng.ant.design/#/components/pagination
step 2: open https://ng.ant.design/#/components/modal
step 3: click button '使用component'
step 4: click browser's back button
step 5: check the page, the modal is still visible

Expected behavior

It likes bug #412

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z

ng-zorro-antd version: X.Y.Z

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@hsuanxyz
Copy link
Member

hsuanxyz commented Oct 17, 2017

Hi @fuybooo:
This is not a BUG, if you used Modal's service, need to control it in the lifecycle hook. like this:

import { Component, OnDestroy } from '@angular/core';
import { NzModalService } from '../../../index.showcase';

@Component({
  selector: 'app-your-component',
  template: `
    <button nz-button [nzType]="'primary'" (click)="showModalForComponent()">
      <span>使用Component</span>
    </button>
  `
})
export class YourComponent implements OnDestroy {
  _modal: any;

  constructor(private modalService: NzModalService) {
  }

  showModalForComponent() {
    this._modal = this.modalService.open({ ... });
  }

  ngOnDestroy() {
    this._modal.destroy('onCancel')
  }
}
  ngOnDestroy() {
+  this._modal.destroy('onCancel')
  }

NzModalSubject.destroy ( type ) - 用于销毁当前的modal对象 - Modal API

@fuybooo
Copy link
Author

fuybooo commented Oct 17, 2017

Ok, thank you very much!

@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants