AngularJS从JSON文件中获取字符串

时间:2014-08-06 13:20:27

标签: json angularjs

我有一个具有此结构的JSON文件

"entities": [
    {
      "id": ,
      "signature": "",
      "title": "",
      "nr": "",
      "class_name": "",
      "tags": [
        {
          "tag_type_id": "",
          "tag_type_name": "",
          "value": ""
        }
      ],
      "attachments": [
        {
          "file_name": "",
          "type": ""
        },
        {
          "file_name": "",
          "type": ""
        }
      ],
      "photo": []
    },

我想在<img src="file_name">中仅显示file_name以显示此图像。 我使用ng-repeat来显示实体中的标题内容,但是如何显示file_name?

1 个答案:

答案 0 :(得分:0)

请参见此处:http://plnkr.co/edit/7PqHaa7sEivJbcekTeUx?p=preview

   <div ng-repeat="ent in entities">
      <img ng-repeat="img in ent.attachments" ng-src="{{img.file_name}}" />
    </div>