2016-10-25 3 views
0

IAMと剣道UIグリッド(私のサーバーからJSON)AJAXによってロードされたグリッドを生成しようとしている2角度と非同期データソース

それを行うための単純な待ち時間は何ですか?

このグリッドに非同期json応答をバインドする方法はありますか?

以下のコードは、私は今日それを行う方法である(ハードコード)

は、あなたがその目的のために非同期パイプを使用することができます

import { Component, OnInit } from '@angular/core'; 
import { HttpService } from 'services/http.service' 

@Component({ 
    selector: 'my-analytics', 
    styleUrls: ['../../../node_modules/@telerik/kendo-theme-default/dist/all.css'], 
    template: require('./analytics.component.html') 

}) 
export class AnalyticsComponent implements OnInit { 

    private gridData: any[] = [{ 
     "ProductID": 1, 
     "ProductName": "Chai", 
     "UnitPrice": 18.0000, 
     "Discontinued": false, 
     "Category": { 
      "CategoryID": 1, 
      "CategoryName": "Beverages", 
      "Description": "Soft drinks, coffees, teas, beers, and ales" 
     } 
    }, { 
     "ProductID": 2, 
     "ProductName": "Chang", 
     "UnitPrice": 19.0000, 
     "Discontinued": false, 
     "Category": { 
      "CategoryID": 1, 
      "CategoryName": "Beverages", 
      "Description": "Soft drinks, coffees, teas, beers, and ales" 
     } 
    }, { 
     "ProductID": 3, 
     "ProductName": "Aniseed Syrup", 
     "UnitPrice": 10.0000, 
     "Discontinued": false, 
     "Category": { 
      "CategoryID": 2, 
      "CategoryName": "Condiments", 
      "Description": "Sweet and savory sauces, relishes, spreads, and seasonings" 
     } 
    }]; 

    constructor(private http_service: HttpService) { } 

    ngOnInit() { 

    } 
} 

答えて

0

Uに感謝します。それぞれのデータBinding help articleを確認してください。

+0

このデモをsubsribeを使用することで、このようにしてみてください – user1310492

1

uはJSONをXMLでのみ動作していない

 this.http.get(this.url) 
     .map(response => response.json()) 
     .subscribe(result => { 
      this.gridData= result 


     }, 
      err => console.log(err) 
     ); 
関連する問題