Gathering detailed insights and metrics for ngx-lazy-dialog
Gathering detailed insights and metrics for ngx-lazy-dialog
Gathering detailed insights and metrics for ngx-lazy-dialog
Gathering detailed insights and metrics for ngx-lazy-dialog
npm install ngx-lazy-dialog
Typescript
Module System
Node Version
NPM Version
TypeScript (77.28%)
JavaScript (12.46%)
SCSS (7.48%)
HTML (2.78%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
22 Commits
1 Forks
1 Watchers
3 Branches
1 Contributors
Updated on Mar 12, 2025
Latest Version
3.0.1
Package Id
ngx-lazy-dialog@3.0.1
Unpacked Size
101.81 kB
Size
20.26 kB
File Count
37
NPM Version
8.5.5
Node Version
16.15.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
1
2
This library allows you to create lazy loading dialogs without the need for root app dependency injections. Each dialog is completely independent of the rest of the application.
The dialog is fully customizable!
Standalone components are supported now!
Version | Angular Version |
---|---|
3.x.x | 15.x.x |
2.x.x | 14.x.x |
1.x.x | 13.x.x |
The ngx-lazy-dialog can be installed with npm:
npm i ngx-lazy-dialog --save
Import LazyDialogModule
in your app root module like app.module.ts
:
1// ... 2import { LazyDialogModule } from 'ngx-lazy-dialog'; 3// ... 4@NgModule({ 5 // ... 6 imports: [ 7 LazyDialogModule.forRoot({ 8 closeOnBackdropClick: true, 9 closeButton: true, 10 }) 11 ], 12 // ... 13}) 14export class AppModule {}
Import styles to styles.scss
of your project:
1@import 'node_modules/ngx-lazy-dialog/styles/ngx-lazy-dialog.scss';
Each dialog component should have your own module, so generate a dialog component and module using Angular CLI:
ng g module dialogs/alert
ng g component dialogs/alert
After generating dialog and module, the folder structure should be like this:
app
└───dialogs
│ │ alert
│ │ │ alert.component.html
│ │ │ alert.component.scss
│ │ │ alert.component.ts
│ │ │ alert.module.ts
We need to modify the alert.component.ts
file if you want to call close function or receive data in the dialog:
1// ... 2import { LazyDialogRef } from 'ngx-lazy-dialog'; 3// ... 4export class AlertComponent implements OnInit { 5 public myData: any 6 7 constructor(private _dialogRef: LazyDialogRef) { 8 } 9 10 ngOnInit() { 11 // getting data 12 this.myData = this._dialogRef.data; 13 } 14 15 close(data?: any) { 16 // closing dialog 17 this._dialogRef.close(data); 18 } 19}
After, we are going to modify alert.module.ts
:
1// ... 2import { ModuleWithLazyDialog } from 'ngx-lazy-dialog'; 3// ... 4export class AlertModule implements ModuleWithLazyDialog<AlertComponent> { 5 // Implementing 'getDialog' to return module bootstrap component 6 getDialog() { 7 return AlertComponent; 8 } 9}
In alert.component.html
file, we can add a simple template as example:
1<p>Alert dialog</p> 2<button (click)="close()">Close</button> 3<button (click)="close({bar: 'foo'})">Close with output data</button>
It's done. Now we are going to open the dialog in another component from our app:
1// ... 2import { LazyDialogService } from 'ngx-lazy-dialog'; 3// ... 4constructor(private _service: LazyDialogService) { 5} 6// ... 7async openDialog() { 8 const module = await import('./dialogs/alert/alert.module').then(m => m.AlertModule); 9 this._service.create({module}); 10} 11//...
You can try to add data and config to dialog creation or get a callback data:
1// ... 2async openDialog(): Promise<void> { 3 const module = await import('./dialogs/alert/alert.module').then(m => m.AlertModule); 4 5 const data = { 6 foo: 'bar' 7 }; 8 9 const config: LazyDialogConfig = { 10 closeOnBackdropClick: false, 11 closeButton: false, 12 customClasses: 'my-custom-class', 13 }; 14 15 const dialog = await this._service.create({module, data, config}); 16 dialog.onClose().then((output) => { 17 console.log(output); 18 }); 19} 20// ...
Generate a standalone dialog component using Angular CLI:
ng g component --standalone dialogs/alert
After generating dialog and module, the folder structure should be like this:
app
└───dialogs
│ │ alert
│ │ │ alert.component.html
│ │ │ alert.component.scss
│ │ │ alert.component.ts
We need to modify the alert.component.ts
file if you want to call close function or receive data in the dialog:
1// ... 2import { LazyDialogRef } from 'ngx-lazy-dialog'; 3// ... 4@Component({ 5 // ... 6 standalone: true 7}) 8export class AlertComponent implements OnInit { 9 public myData: any 10 11 constructor(private _dialogRef: LazyDialogRef) { 12 } 13 14 ngOnInit() { 15 // getting data 16 this.myData = this._dialogRef.data; 17 } 18 19 close(data?: any) { 20 // closing dialog 21 this._dialogRef.close(data); 22 } 23}
In alert.component.html
file, we can add a simple template as example:
1<p>Alert dialog</p> 2<button (click)="close()">Close</button> 3<button (click)="close({bar: 'foo'})">Close with output data</button>
It's done. Now we are going to open the dialog in another component from our app:
1// ... 2import { LazyDialogService } from 'ngx-lazy-dialog'; 3// ... 4constructor(private _service: LazyDialogService) { 5} 6// ... 7async openDialog() { 8 const component = await import('./dialogs/alert/alert.component').then(m => m.AlertComponent); 9 this._service.create({component}); 10} 11//...
You can try to add data and config to dialog creation or get a callback data:
1// ... 2async openDialog() { 3 const component = await import('./dialogs/alert/alert.component').then(m => m.AlertComponent); 4 5 const data = { 6 foo: 'bar' 7 }; 8 9 const config: LazyDialogConfig = { 10 closeOnBackdropClick: false, 11 closeButton: false, 12 customClasses: 'my-custom-class', 13 }; 14 15 const dialog = await this._service.create({component, data, config}); 16 dialog.onClose().then((output) => { 17 console.log(output); 18 }); 19} 20// ...
You can customize the dialog container and backdrop using CSS variables. See the list of variables and their default values below:
Var | Default | Description |
---|---|---|
--dialog-backdrop-bg | rgba(0, 0, 0, 0.25) | Backdrop color |
--dialog-bg | #FFFFFF | Container background color |
--dialog-padding | 24px | Container padding |
--dialog-border-radius | 8px | Container border radius |
--dialog-shadow | rgba(9, 30, 66, 0.25) 0 4px 8px -2px, rgba(9, 30, 66, 0.08) 0 0 0 1px) | Container box shadow |
--dialog-max-width | 90vw | Max container width |
--dialog-max-height | 90vh | Max container height |
--dialog-min-width | 200px | Min container width |
--dialog-min-height | 100px | Min container height |
--dialog-z-index | 1001 | Z-index |
--dialog-close-color | #000000 | Close icon color |
--dialog-close-size | 24px | Close icon size |
--dialog-close-position | 24px | Close icon position |
--dialog-animation-duration | 160ms | Animation duration |
Example:
Add custom css vars to your app global style file (like styles.scss):
1:root { 2 --dialog-bg: #E7EAEF; 3 --dialog-close-color: #123661; 4}
Or create a css class and add to dialog creation:
1.custom-dialog { 2 --dialog-bg: #E7EAEF; 3 --dialog-close-color: #123661; 4}
1this.service.create({component, data, config: {customClasses: 'custom-dialog'}});
ngx-lazy-dialog.scss
file to your app global style file (like styles.scss)create
function on LazyDialogService
. Now you need to pass only one object: LazyDialogCreateConfig
.No vulnerabilities found.
No security vulnerabilities found.