ng2-modal-Dialog is a fully generic, customizable, and factory-fluent modal window implementation for Angular2. The only dependency of this module is angular itself, which works with any method preprocessor where the conditional component itself is generated during runtime.
angular lazy load dialog, angular 2 modal popup example, dynamic dialog primeng, load dynamic components inside a modal dialog in angular
How to make use of it:
Installation:
npm install --save ng2-modal-dialog
1. Import the module into app.module.ts
a file and conditional component.
import { ModalModule } from 'ng2-modal-dialog/modal.module'; import { LoginModalComponent } from './login-modal/login-modal.component'; ... declarations: [ ... LoginModalComponent ], imports: [ ... ModalModule ],
2. Add a placeholder in app.componenet.html
<h1> {{title}} </h1> <a href="javascript:void(0);" (click)="openLoginModal(passedParameter = { username: 'user', password: 'pass' })">Login</a> <!-- the place holder for all modals that will be opened --> <modal-placeholder></modal-placeholder>
3. In the conditions parent component, you will need to import the following.
import { ModalService } from 'ng2-modal-dialog/modal.module'; import { LoginModalComponent } from './login-modal/login-modal.component'; // The AppModule from the application src import { AppModule } from './app.module'; ... // Instancing a new ModalService in the parent component constructor constructor(private modalService: ModalService) { } // Click function to open the modal openLoginModal(userCreds): void { // Service callback function to create the modal with an object passed as a parameter this.modalService.create(AppModule, LoginModalComponent, {userCreds}); }
angular2 factory made modal dialog, ng2-modal-dialog Plugin/Github
See Demo And Download
Official Website(DanielNetzer): Click Here
This superior jQuery/javascript plugin is developed by DanielNetzer. For extra advanced usage, please go to the official website.