Gathering detailed insights and metrics for ng2-router-modal
Gathering detailed insights and metrics for ng2-router-modal
Gathering detailed insights and metrics for ng2-router-modal
Gathering detailed insights and metrics for ng2-router-modal
Angular2 module that integrates ng-bootstrap modal with ui-router state's tree.
npm install ng2-router-modal
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
34 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 02, 2017
Latest Version
0.0.8
Package Id
ng2-router-modal@0.0.8
Size
5.27 kB
NPM Version
3.10.10
Node Version
6.9.4
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
Angular2 module that integrates ng-bootstrap modal with ui-router state's tree.
DISCLAIMER! this module is still under high development; If you have suggestions and or problems feel free to post them on issues.
npm install ng2-router-modal
and add to AppModule and initialize modal states initialization at UIRouter config function,
1@NgModule({
2 imports: [
3 ...
4 UIRouterModule.forRoot({
5 ...
6 config: function(router: UIRouter, injector: Injector){
7 let rmService = injector.get(RmService);
8 let states = injector.get(StateService).get();
9 rmService.initModalStates(states);
10 ...
11 }
12 }),
13 ResourceModule.forRoot()
14 ],
15})
Start by creating a service that extends RmService. Declare the modal params with @ModalParams and action specific params with @ModalAction annotations.
1import {RmModal, ModalParams, ModalAction} from "ng2-router-modal"; 2import {ThingModalComponent} from "./thing-modal.component"; 3 4import {NgbModalRef} from "@ng-bootstrap/ng-bootstrap"; 5 6@Injectable() 7@ModalParams({ 8 name: 'thing', 9 component: ThingModalComponent 10}) 11export class ThingModal extends RmModal { 12 13 @ModalAction({}) 14 create: NgbModalRef; 15 16 @ModalAction({ 17 urlParams: '{id:int}' 18 }) 19 update: NgbModalRef; 20 21}
./thing-modal.component.ts is your regular component containing the ng-bootstrap Modal:
1@Component({
2 selector: 'thing-modal',
3 templateUrl: 'thing-modal.html',
4 ...
5})
6export class ThingModalComponent implements OnInit{
7
8 constructor(private activeModal: NgbActiveModal, private rmService: RmService, ...) {
9 }
10
11 ngOnInit(){
12 console.log(rmService.params.id);
13 }
14 ...
15}
add/link the modal to an existing state (./some-module.states.ts):
1name: 'somePage', 2url: '/somepage', 3component: SomepageComponent, 4data: { 5 ... 6 modals: [ 7 ThingModal 8 ] 9} 10...
Open your modal at your-website/somepage/create-thing
to create a new Thing or your-website/somepage/update-thing/123
to update an existing Thing. You can update the modal pragmatically via the state names (do not forget to pass the parameters).
1<a uiSref='somePage.createThing'>New Thing</a> 2<a uiSref='somePage.updateThing' [uiParams]='{id: 123}'>Update Thing 123</a>
The handler is called every time the modal/action is closed/dismissed. do not forget to unsubscribe the observers
1export class SomepageComponent implements OnDestroy { 2 3 constructor(private rmService: RmService ... ){ 4 this.thingCloseSub = rmService.onClose(['createThing', 'updateThing']).subscribe((thing: any) => { 5 console.log(thing) 6 }); 7 8 this.thingDismissSub = rmService.onDismiss(['createThing']).subscribe((thing: any) => { 9 console.log('user dismissed modal when creating a thing'); 10 }); 11 ... 12 } 13 14 ngOnDestroy(): void { 15 this.thingCloseSub.unsubscribe(); 16 this.thingDismissSub.unsubscribe(); 17 } 18} 19...
Using the open
method you can use the returned promise or the onClose
/onDismiss
methods to receive the result.
1export class NavbarComponent { 2 3 constructor(private rmService: RmService ... ){} 4 5 openThing(): void { 6 this.rmService.open(ThingModal, 'create', {someparam: 'some value'}).then( 7 thing => (console.log(thing), 8 msg => console.log('user dismissed modal with ' + msg ) 9 ); 10 } 11} 12...
(in progress)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
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