如何使用ng-repeat获取完整的文件?

时间:2018-04-16 08:29:45

标签: angularjs angularjs-ng-repeat

我有一个JSON对象。我想用ng-repeat显示数据。我想使用ng-repeat加载Project: ManojProject: Rainer中的所有文件。

预期输出

使用ng-repeat

Manoj所有项目

使用ng-repeat

Rainer所有项目

以下是我的JSON

[
    {
        "folderName": "manoj",
        "files": [
            {
                "filename": "FLIP_Libraries_v1.6.zip",
                "path": "manoj/FLIP_Libraries_v1.6.zip"
            },
            {
                "filename": "blog-img-1.jpg",
                "path": "manoj/blog-img-1.jpg"
            },
            {
                "filename": "blog-post-1.jpg",
                "path": "manoj/blog-post-1.jpg"
            }
        ]
    },
    {
        "folderName": "rainer",
        "files": [
            {
                "filename": "blog-img-1.jpg",
                "path": "rainer/blog-img-1.jpg"
            },
            {
                "filename": "blog-post-4.jpg",
                "path": "rainer/blog-post-4.jpg"
            },
            {
                "filename": "comment-img-1.png",
                "path": "rainer/comment-img-1.png"
            }
        ]
    }
]

1 个答案:

答案 0 :(得分:0)

尝试这样的事情。它只有两个VideoDownloader:一个用于文件夹,一个用于文件。



ng-repeat

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.json = [{
      "folderName": "manoj",
      "files": [{
          "filename": "FLIP_Libraries_v1.6.zip",
          "path": "manoj/FLIP_Libraries_v1.6.zip"
        },
        {
          "filename": "blog-img-1.jpg",
          "path": "manoj/blog-img-1.jpg"
        },
        {
          "filename": "blog-post-1.jpg",
          "path": "manoj/blog-post-1.jpg"
        }
      ]
    },
    {
      "folderName": "rainer",
      "files": [{
          "filename": "blog-img-1.jpg",
          "path": "rainer/blog-img-1.jpg"
        },
        {
          "filename": "blog-post-4.jpg",
          "path": "rainer/blog-post-4.jpg"
        },
        {
          "filename": "comment-img-1.png",
          "path": "rainer/comment-img-1.png"
        }
      ]
    }
  ]


});