1

ajax (サーバーからの JSON) によってロードされたグリッドを生成しようとしています

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

このグリッドに非同期の 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() {

    }
}
4

2 に答える 2

1

あなたは購読を使ってこのように試すことができます

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


        },
             err => console.log(err)
        );
于 2016-11-02T09:55:41.407 に答える
0

そのために非同期パイプを使用できます。それぞれのデータバインディングのヘルプ記事を確認してください。

于 2016-10-25T13:18:34.037 に答える