简体   繁体   中英

Display ng-grid with nested array of JSON objects?

I have some JSON data that looks like so:

return {
    "activityTypes" :[{
        "id" :"",
        "name:" :"",
        "icon" : "",
        "partial": "",
        "label" : {
            "id": "",
            "name": ""
        }
    }],
    "apiKey" : "",
    "approveBy": 0,
    "approvers" : [], 
    "canSendTo" : [{
        "id" : "",
        "name" : ""
    }],  
    "creators" : [],
    "isActive" : false,
    "notification" : false, 
    "sourceId": "",
    "sourceName":""
};

I am trying to use ng-grid, but I am trouble trying to access the elements inside an array of objects, such as the activityTypes or canSendTo arrays. In the following example, I tried to display canSendTo's id. I've tried the following but it does not render on the screen. Any ideas on how to fix this? Thanks!

{field: 'canSendTo.id', displayName: 'Can Send To', width:'10%',
    cellTemplate: '<div class="ngCellText", style="white-space: normal;">{{row.getProperty(col.field)}}</div>'},

我对ng-grid一无所知,但是从直接的javascript角度来看,它应该是canSendTo [0] .id,因为canSendTo是一个单元素数组。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM