npm install ngx-easy-modal --save
- Add to import Modules and Add to entry entryComponents in @NgModules, the modules that you want to put inside the modal.
@NgModule({
declarations: [
AppComponent,
SampleModalComponent,
],
entryComponents: [
SampleModalComponent
],
imports: [
BrowserModule,
FormsModule,
NgxModalModule,
],
providers: [],
bootstrap: [AppComponent]
})
- Import your Service in a component and Create a new Modal.
export class AppComponent {
constructor(private modalService: NgxModalService) {
}
openModal(){
const params = {};
this.modalService.create(SampleModalComponent, params).then((modal: NgxModal) => {
modal.open();
});
}
}
functions:
- open() -> to open modal;
- close() -> to close modal;
- destroy() -> to open modal;
events:
- onOpen
- onClose
- onDestroy
In Params, you can add all params that you need for init your component, but for modal, you can pass this params:
- enableBackdropDismiss (boolean)
- class (Array of strings)