无法从IONIC中的嵌套JSON数据中获取键和值

时间:2016-12-14 07:26:22

标签: json cordova ionic-framework angularjs-ng-repeat ng-repeat

我现在遇到一个问题,我无法从嵌套的JSON数据中获取密钥和值。请帮助我,我做错了。

<ion-item class="item item-thumbnail-left item-text-wrap" type="item-text-wrap" nav-transition="android" ng-repeat="data in hrINPROCandidateList | filter:search">
    <p class="small-text blue-text ">{{data.cfname}}</p>
    <div class="row" ng-repeat="(key,value) in data.note_detail_fields track by $index">
      <div class="col field">{{key}}</div>
      <div class="col field-info">{{value}}</div>
    </div>
</ion-item>

JSON数据

{
"responseToken": 1,
"list": [
    {
        "candidate_id": "4",
        "note_detail_fields": "{\"link\":\"View Interview Details\",\"job_title\":\"Sopra Executive\",\"Candidate\":\"Mark Ashton\",\"Interview_Type\":\"First Interview\",\"\":\"\",\"Duration\":\"30 minutes\",\"Date\":\"Wednesday, 23<sup>rd<\\/sup> November 2016\",\"Time\":\"09:00 to 09:30\",\"Location\":\"london\"}",
        "cfname": "Idris",
        "clname": "Alba"
    },
    {
        "candidate_id": "506",
        "note_detail_fields": null,
        "cfname": null,
        "clname": null
    },
    {
        "candidate_id": "32",
        "note_detail_fields": "{\"link\":\"View Shared Job\",\"job_title\":\"Manager\",\"Location\":\"London, United Kingdom\",\"Package\":\"800 - 850 per day GBP\"}",
        "cfname": "Sajal",
        "clname": "Agarwal"
    }
],
"totalCount": "4",
"success": 1,
"status": null
}

在应用中查看数据

View data in app

1 个答案:

答案 0 :(得分:2)

你试图循环一个字符串而不是一个数组,创建一个解析data.note_detail_fields

中包含的json的过滤器
<div class="row" ng-repeat="(key,value) in data.note_detail_fields | fromJson track by $index">
  <div class="col field">{{key}}</div>
  <div class="col field-info">{{value}}</div>
</div>


app.filter('fromJson',function(){
    return function(input){ return angular.fromJson(input); }
})