Basically a replacement for NG Bootstrap's modals implementation.
For a demo's and examples visit the demo site.
NG Bootstrap does a great job of abstracting Bootstrap's controls and widgets.
The only thing I do not agree on is their implementation of the modals:
- Direct access to the modal component's instance to inject data (inputs).
- No clear separation in api of how a modal was completed (dismiss or resolved)
- The use of entry components
- Modal components use DI injector of the module where they were spawned.
This library tries to fix these issues by merging NG Bootstrap's implementation with the one from Angular Material.
- It uses (encapsulated) DI injector to pass settings and data to the hosted modals
- The
ModalRef
now has the following outputs:onResolve: Observable<T>
emits and complets when the modal resolves with a value.onDismiss: Observable<void>
emits and completes when the modal is dismissed by the user pressing escape, clicking the close button or outside the container.onComplete: Observable<void>
emits and completes on resolved and dismissed.
- You no longer need to export your modal component as entry component. The way of constructing components is completely different.
- Injection is now inherited from the module which exports the component.
Peer dependencies:
- @angular/common:
^11.2.1
- @angular/core:
^11.2.1
- @angular/animations:
^11.2.1
- bootstrap:
~4.5.0
You will need to authorize to Github packages for the @juraji
scope.
If you have never done this before, read up on Configuring npm for use with GitHub Packages.
Just for reference, here's what my .npmrc
looks like:
@juraji:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=MY_PERSONAL_ACCESS_TOKEN
The above configuration is the same for NPM and Yarn.
It will route NPM and yarn to only use Github packages for the @juraji
scope.
For more information on Github personal access tokens check your developer settings.
- Install
@juraji/ng-bootstrap-modals
.- For Yarn use
yarn add @juraji/ng-bootstrap-modals
. - For NPM use
npm install @juraji/ng-bootstrap-modals
.
- For Yarn use
- Add
ModalModule.forRoot()
to your root module. - Use the
Modals
service to open components as modals.
For examples visit the demo site!