ng2-jsgrid

Installation

To install this library, run:

$ npm install ng2-jsgrid --save

Consuming your library

Once you have published your library to npm, you can import your library in any Angular application by running:

$ npm install ng2-jsgrid

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import
import { GridModule } from 'ng2-jsgrid';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    GridModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once your library is imported, you can use its components, directives and pipes in your Angular application:

import { Component, OnInit } from '@angular/core';
import { Field } from 'ng2-jsgrid';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  fields: Field[];
  api = async (filter) => {
    // Call from API with current filter
    // Some samples:
    // const result = await this._someService.getDate(filter).toPromise();

    console.log(filter);

    const promise = new Promise((res) => {
      setTimeout(() => {
        res({
          itemsCount: 12,
          data: [
            { name: 'John', age: 30 },
            { name: 'Smith', age: 46 },
          ]
        });
      }, 3000);
    });

    const result = await promise;
    return result;
  }
  ngOnInit(): void {
    this.fields = [
      { name: 'name', title: 'Name' },
      { name: 'age', title: 'Age' }
    ];
  }
}

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

MIT © jinhduong

results matching ""

    No results matching ""