question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal: string argument to the open method is confusing

See original GitHub issue

See http://stackoverflow.com/q/39464345/1418796

Really, the string argument is only good for unit-testing but not for any real-life applications. We should remove it altogether or at least clarify in the docs.

On top of this we need to support components as arguments to the open method, see #680

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SanderEliascommented, Sep 23, 2016

My vote would go on removing the string argument completely, as it’s just utterly confusing. Adding the component support to the open method makes a lot of sense. This will take out quite some boileplate code that is now needed to support the usecase of #680

1reaction
felixfbeckercommented, Sep 17, 2016

How about something like

ngbModal.open(MyModalComponent).then(value => ...

where the component is passed the modal instance as an @input?

to avoid having to specify @Input it could also be possible to subclass a ModalComponent:

import {ModalComponent} from '@ng-bootstrap/ng-bootstrap'

@Component({})
class MyModalComponent extends ModalComponent {
  ngOnInit() {
    this.modal.close(value) // or
    this.modal.dismiss(value)
  }
}

where ModalComponent is something like:

abstract class MyModalComponent {
  @Input()
  public modal: ModalInstance
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practice for calling the NgbModal open method
The string -typed argument is not very interesting - in fact it was mostly added to aid debugging / unit-testing. By using it...
Read more >
Value of a parameter in the query string causes a new page to ...
I want to use this value as the parameter (with a different name) in a link to open a modal dialog box. $('#my-element').after(' ......
Read more >
Modal · Issue #3 · ng-bootstrap/ng-bootstrap - GitHub
One approach to explore would be to allow passing component types as argument to the open method. And in this case we could...
Read more >
showModalDialog method (Internet Explorer) - Microsoft Learn
Creates a modal dialog box that displays the specified HTML document. Syntax. var retval = window.showModalDialog(dialog, varArgIn, varOptions); ...
Read more >
views.open method - Slack API
Open a modal with a user by exchanging a trigger_id received from another interaction. See the modals documentation to learn how to obtain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found