Gathering detailed insights and metrics for ng2-modal-module
Gathering detailed insights and metrics for ng2-modal-module
Gathering detailed insights and metrics for ng2-modal-module
Gathering detailed insights and metrics for ng2-modal-module
bootstrap modal component adjusted for angular2! framework based on rx-pubsub service. NO jQuery!!!
npm install ng2-modal-module
Typescript
Module System
Node Version
NPM Version
TypeScript (73.13%)
JavaScript (12.94%)
HTML (12.49%)
CSS (1.45%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
6 Commits
1 Forks
28 Branches
1 Contributors
Updated on Jun 26, 2019
Latest Version
1.0.1
Package Id
ng2-modal-module@1.0.1
Unpacked Size
194.50 kB
Size
39.50 kB
File Count
26
NPM Version
6.9.0
Node Version
12.4.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
ng2-modal-module
or ModalModule
is a module for angular2+ which
exposes the bootstrap (3.3.*) modal component (no jQuery required!!!)
with the util class Ng2ModalWindow
which makes the component usage
easier.
It is based on pubsub-distinct.
Install the module into your application and save it as a dev
dependency in your package.json
file
npm install ng2-modal-module --save-dev
WARNIGNG Don't forget to include the bootstrap (3.3.*) styles!
In order to use the ModalModule
module you have to include/import
it into your application:
import {ModalModule} from 'ng2-modal-module';
Add the module into the app's module imports
section:
1import { ModalModule } from 'ng2-modal-module'; 2 3@NgModule({ 4 //... 5 imports: [ 6 //... 7 ModalModule // <<--- HERE 8 ], 9 //... 10})
Include the modal
component into your template:
1<ng2-modal-window id="{{modalId}}"></ng2-modal-window>
where modalId
is a unique ID of the modal component.
Call the modal component (display or hide it) using the Ng2ModalWindow
util class:
1import { Component, OnInit } from '@angular/core'; 2import { Ng2ModalWindow } from 'ng2-modal-module'; 3 4export class AppComponent implements OnInit { 5 modalId: string = 'modalId'; 6 7 constructor() { 8 } 9 10 ngOnInit() { 11 Ng2ModalWindow.showModal(this.modalId, { 12 title: 'Modal title', 13 htmlContent: 'Modal content' 14 }); 15 } 16}
Display the Ng2ModalWindowComponent
Parameters:
modalId - Id of the modal window which should be displayed
options - Options used to customize the displayed modal window
The options list is described here.
Return:
Method returns nothing - void
.
Hide the Ng2ModalWindowComponent
Parameters:
modalId - Id of the modal window which should be hidden
Return:
Method returns nothing - void
.
Reset (remove) the events subscribers of the Ng2ModalWindowComponent
actions buttons if such events are provided using the options
parameter.
Parameters:
eventsList - List of events name which should be removed/unsubscribed
Return:
Method returns nothing - void
.
Option | Type | Default | Description | Example |
---|---|---|---|---|
componentInputs | Object | NULL | Properties list of the dynamically injected component into the modal's body | {title: 'new value of the title property of the injected component'} |
componentSelector | String | NULL | Selector of the component which should be injected dynamically into the modal's body | {componentSelector: 'test-component'} |
customClass | String | NULL | Custom class which will be attached to the modal window. Here can be passed the bootstraps classes which handle the size of the modal (modal-lg , modal-sm etc.) | {customClass: 'modal-lg'} |
hide | Boolean | NULL | Forcibly hide the modal window when its value is true | {hide: true} |
htmlContent | String | Empty | The HTML content which should be injected in the modal's body as innerHTML content (HTML tags are not escaped!) | {htmlContent: '<strong>test content</strong>'} |
overlayClick | Boolean | true | Enable/disable the click over the modal's overlay. If it's true then the click over the overlay hides/closes the modal window. | {overlayClick: false} // disable the overlay click |
show | Boolean | NULL | Forcibly shows/display the modal window if its value is true | {show: true} |
showEvent | String | NULL | Name of the event which will be triggered when the modal window is displayed | {showEvent: 'show-event'} |
title | String | Empty | Title of the modal window | {title: 'Modal window title'} |
buttons.visible | Boolean | true | Display or hide the footer section with the action buttons (cancel/success). true - buttons are visible false - buttons are hidden | {buttons: {visible: false}} // hide buttons |
buttons.cancel.visible | Boolean | true | Display or hide the cancel button true - button is visible false - button is hidden | {buttons: {cancel: {visible: false}}} // hide cancel button |
buttons.cancel.label | String | 'Cancel' | Label of the cancel button | {buttons: {cancel: {label: 'Close'}}} |
buttons.cancel.event | String | NULL | Name of the event which will be triggered (using pubsub-distinct) when the cancel button is clicked | {buttons: {cancel: {event: 'cancel-event'}}} |
buttons.success.visible | Boolean | true | Display or hide the success button true - button is visible false - button is hidden | {buttons: {success: {visible: false}}} // hide success button |
buttons.success.label | String | 'Save' | Label of the success button | {buttons: {success: {label: 'Save changes'}}} |
buttons.success.event | String | NULL | Name of the event which will be triggered (using pubsub-distinct) when the success button is clicked | {buttons: {cancel: {event: 'success-event'}}} |
Before using the Ng2ModalWindowComponent
don't forget to import the Ng2ModalWindow
util class into your component/service:
1import { Ng2ModalWindow } from 'ng2-modal-module'; 2 3//... 4// define an unique ID for the modal component 5modalId: string = 'test-modal-window'; 6//...
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 htmlContent: 'Modal content' 4});
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 htmlContent: '<b>test bold</b> and simple text', 4 customClass: 'modal-lg', 5 overlayClick: false 6});
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 htmlContent: 'modal content', 4 buttons: { 5 visible: false 6 } 7});
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 htmlContent: 'modal content', 4 buttons: { 5 success: {visible: false} 6 } 7});
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 componentSelector: 'app-test' 4});
where app-test
is the selector of the component which should be injected in the modal window.
WARNING! To make it dynamically injectable, the component app-test
should be included in the entryComponents: []
list of the @NgModule(...)
of your application module;
1Ng2ModalWindow.showModal(this.modalId, { 2 title: 'Modal title', 3 componentSelector: 'app-test', 4 componentInputs: {componentTitle: 'CUSTOM TITLE'} 5});
where componentTitle
is a public property of the component app-test
.
1// events names 2let successEventName = 'successEvent'; 3let cancelEventName = 'cancelEvent'; 4 5// remove previously added subscriber and publisher 6Ng2ModalWindow.resetEventsSubscribers([successEventName, cancelEventName]); 7 8// pass the events name to the modal window component 9Ng2ModalWindow.showModal(this.modalId, { 10 title: 'Modal title', 11 htmlContent: 'listen actions events', 12 buttons: { 13 cancel: { event: cancelEventName }, 14 success: { event: successEventName } 15 } 16}); 17 18// subscribe to events 19Ng2ModalWindow.subscribe(successEventName, (data) => { 20 console.log('successEventName triggered!', data); 21 // hide modal 22 Ng2ModalWindow.hideModal(this.modalId); 23}); 24Ng2ModalWindow.subscribe(cancelEventName, (data) => { 25 console.log('cancelEventName triggered!', data); 26});
Before registering new events listeners, is suggested to remove them if they are already subscribed to the same events:
1Ng2ModalWindow.resetEventsSubscribers([successEventName, cancelEventName]);
1Ng2ModalWindow.hideModal(this.modalId);
https://github.com/kageoni/ng2-modal-module
To build the final package run this command:
ng build ng2-modal
The build process will generate the packed sources into the dist
folder.
To publish the new version to npm
, go into the dist
folder:
cd ./dist/ng2-modal
and publish it to npm:
npm publish
1.0.1
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
144 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More