angular - don't show data in ag-grid -


i using ag-grid in angular4. want show data using api getting method. api ok , getting data in console. can not able show data in ag-grid. not understand problem here. when compile project, there no error shown. project runs in browser , showing header name not show data come api.

my ts file:

import {component, oninit} '@angular/core'; import {gridoptions} 'ag-grid'; import {http} '@angular/http';  @component({ selector: 'app-my-grid-application', templateurl: './my-grid-application.component.html', styleurls: ['./my-grid-application.component.css'] })  export class mygridapplicationcomponent implements oninit {  public gridoptions: gridoptions; public columndefs = []; public rowdata = [];  constructor(public http: http) { this.gridoptions = <gridoptions>{   rowdata: [],   columndefs: [     {       headername: 'id',       field: 'id'     },     {       headername: 'name',       field: 'name'     }   ] } 

this method of api link

ngoninit() { const url = 'http://localhost:3000/studentinfo/students'; this.http.get(url).subscribe(   res => {     this.gridoptions = res;   },   msg => {     console.error(`error: ${msg.status} ${msg.statustext}`);   } ); } } 

this html file define grid presentation

my html file:

  <ag-grid-angular #aggrid style="width: 650px; height: 200px;" class="ag-   fresh" [gridoptions]="gridoptions"  [columndefs]="columndefs    [rowdata]="rowdata">   </ag-grid-angular> 

i have solved problem in way.......

ngoninit() { const url = 'http://localhost:3000/studentinfo/students'; this.http.get(url).subscribe(   res => {     this.rowdata = res.json();   },   msg => {     console.error(`error: ${msg.status} ${msg.statustext}`);   } ); 

}

and html:

<ag-grid-angular #aggrid style="width: 650px; height: 200px;" class="ag-fresh"                [gridoptions]="gridoptions" [rowdata]="rowdata"> 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -