Created
August 15, 2018 05:50
-
-
Save cchng/eb2a0e054db45f1a7abbb7fa50b47603 to your computer and use it in GitHub Desktop.
display a table with angular grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnDestroy, OnInit } from '@angular/core'; | |
| import { HttpClient } from '@angular/common/http'; | |
| import { AgGridModule } from 'ag-grid-angular'; | |
| @Component({ | |
| templateUrl: 'myobject.component.html' | |
| }) | |
| export class MyObjectComponent implements OnInit { | |
| title = 'app'; | |
| columnDefs = [ | |
| {headerName: 'Object Name', field: 'object_name' }, | |
| {headerName: 'Object Field 1', field: 'object_field_1' }, | |
| ]; | |
| rowData: any; | |
| constructor(private http: HttpClient) { | |
| } | |
| ngOnInit() { | |
| // api returns json containing data with columnDef fields as keys | |
| // TODO: figure out how to get nested data | |
| this.rowData = this.http.get('http://localhost:3000/api/myobject'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment