From bf5eb7bdfbf11b15f6b8693cf780d82898c77880 Mon Sep 17 00:00:00 2001 From: Iurii Panarin Date: Fri, 26 Apr 2019 15:13:47 +0200 Subject: [PATCH] fix(lazy-load): add lazy load support --- README.md | 2 +- lib/src/ngVirtualTable.module.ts | 31 +++++++++------------- lib/src/services/ngVirtualTable.service.ts | 7 +++-- package.json | 2 +- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 73e4b0f..7d7f1c7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Make sure you have: ```typescript import { NgVirtualTableModule } from 'ng-virtual-table'; -imports: [NgVirtualTableModule.forRoot()], +imports: [NgVirtualTableModule], ``` ```html diff --git a/lib/src/ngVirtualTable.module.ts b/lib/src/ngVirtualTable.module.ts index ee89ee7..20c0124 100644 --- a/lib/src/ngVirtualTable.module.ts +++ b/lib/src/ngVirtualTable.module.ts @@ -1,17 +1,18 @@ -import { NgModule, ModuleWithProviders, EmbeddedViewRef } from '@angular/core'; +import { CdkVirtualForOf, CdkVirtualForOfContext, ScrollingModule } from '@angular/cdk/scrolling'; +import { EmbeddedViewRef, ModuleWithProviders, NgModule } from '@angular/core'; + +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { CommonModule } from '@angular/common'; -import { MatPaginatorModule } from '@angular/material/paginator'; -import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; -import { ScrollingModule, CdkVirtualForOf, CdkVirtualForOfContext } from '@angular/cdk/scrolling'; import { DragDropModule } from '@angular/cdk/drag-drop'; -import { VirtualTableComponent } from './components/virtual-table.component'; -import { ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { MatIconModule } from '@angular/material/icon'; -import { MatFormFieldModule } from '@angular/material/form-field'; import { DynamicModule } from 'ng-dynamic-component'; -import { NgVirtualTableService } from './services/ngVirtualTable.service'; import { LayoutModule } from '@angular/cdk/layout'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatPaginatorModule } from '@angular/material/paginator'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { NgVirtualTableService } from './services/ngVirtualTable.service'; +import { ReactiveFormsModule } from '@angular/forms'; +import { VirtualTableComponent } from './components/virtual-table.component'; CdkVirtualForOf.prototype['_updateContext'] = function(this: any) { const count = this._data.length; @@ -32,7 +33,6 @@ CdkVirtualForOf.prototype['_updateContext'] = function(this: any) { imports: [ CommonModule, ReactiveFormsModule, - BrowserAnimationsModule, MatIconModule, MatFormFieldModule, ScrollingModule, @@ -44,11 +44,4 @@ CdkVirtualForOf.prototype['_updateContext'] = function(this: any) { ], exports: [VirtualTableComponent], }) -export class NgVirtualTableModule { - public static forRoot(): ModuleWithProviders { - return { - ngModule: NgVirtualTableModule, - providers: [NgVirtualTableService], - }; - } -} +export class NgVirtualTableModule {} diff --git a/lib/src/services/ngVirtualTable.service.ts b/lib/src/services/ngVirtualTable.service.ts index f3663d7..d682c10 100644 --- a/lib/src/services/ngVirtualTable.service.ts +++ b/lib/src/services/ngVirtualTable.service.ts @@ -1,4 +1,3 @@ -import { Injectable } from '@angular/core'; import { VirtualTableColumn, VirtualTableColumnInternal, @@ -6,7 +5,11 @@ import { sortColumn, } from '../interfaces'; -@Injectable() +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root', +}) export class NgVirtualTableService { public defaultComparator(a: any, b: any): number { if (a > b) { diff --git a/package.json b/package.json index 68b9b23..f40c66b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng-virtual-table", - "version": "1.0.45", + "version": "1.0.46", "description": "Angular 7 virtual scroll table with support dynamic component, draggable, filtering, server side, sorting, pagination, resizable and custom config column", "main": "index.js", "repository": "git@github.com:PxyUp/ng-virtual-table.git",