15.1.1 • Published 9 months ago

ngx-lazy-directive v15.1.1

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

Getting Started

ngx-lazy-directive provides an easy way to lazy load components combined with *ngIf directive, thereby reducing the Firrst Contentful Paint time when a module becomes larger.

Angular Version

  • Support for Angular version 15

Installation

npm install ngx-lazy-directive

Usage

  1. Define a list of components should be lazy loaded.

Note: components should be standalone.

export const LAZY_LOADED_COMPONENTS = {
 'app-chart': () => import('src/app/dashboard/components/chart.component.ts')
}
  1. Pass the import function to the loadChild property.
<ng-container
     *ngIf="visible"
     ngxLazyDirective
     [loadChild]="LAZY_LOADED_COMPONENTS['app-chart']">
</ng-container>
  1. Pass binding data and event handlers to the lazy loaded component using the inputs and outputs properties.
<ng-container
    *ngIf="visible"
    ngxLazyDirective
    [loadChild]="LAZY_LOADED_COMPONENTS['app-chart']"
    [inputs]="{
      dataSource: dataSource,
      name: name
    }"
    [outputs]="{
      nameChanged: onNameChanged
    }">
</ng-container>
  1. Define event handlers.
// Event handlers must be arrow functions
onNameChanged = (name: string) => {
  this.name = name;
}
15.1.1

9 months ago

14.1.1

9 months ago

15.1.0

9 months ago

14.1.0

9 months ago

15.0.0

9 months ago

15.0.1

9 months ago

14.0.0

9 months ago

14.0.1

9 months ago

14.0.2

9 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago