No provider for NgbActiveModal! => “Components as content”

Bug description:

When trying to implement the Modal using a component like the example here “Components as content”
https://ng-bootstrap.github.io/#/components/modal/examples
It works like so.
However I want to also use that component outside of a modal, but when I try to access that component using its selector I get the error:
“Unhandled Promise rejection: No provider for NgbActiveModal! ; Zone: ; Task: Promise.then ; Value: Error: No provider for NgbActiveModal!”

Link to minimally-working plunker that reproduces the issue:

https://plnkr.co/edit/hZMD3vWphJEm7dwLxVEU?p=preview
You’ll see in the console as soon as the app loads, it will throw the error.

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 4.2.4

ng-bootstrap: 1.0.0-beta.1

Bootstrap: 4.0.0-alpha.6

4 thoughts on “No provider for NgbActiveModal! => “Components as content”

  1. This works as designed – you can’t access NgbActiveModal outside of the modal context: the NgbActiveModal injectable is provided by the modal service.

    Not sure what you exact use-case is so hard to suggest anything…