使用 ng-repeat 获取多维数值数组

getting multidimensional numeric array with ng-repeat

我使用 $http.get 从 json 文件中获取数组,如下所示: {user_id:{script_id,cron_format...}

{"1":{"1":"*\/3 * * * *","2":"*\/6 * * * *","3":"*\/3 * * * *","4":"* * * * *"},
"2":{"1":"*\/3 * * * *","2":"*\/2 * * * *","3":"*\/Al test","4":"* * * * *"},
"3":{"1":"*\/3 * * * *","2":"*\/6 * * * *","3":"*\/3 * * * *","4":"12 "}}

我试图将所有值放在三列中 table 但我不知道如何获取所有值: 最好的尝试只有 script_id 和 cron_format:

 <table class="table table-bordered table-hover">
        <thead>
            <td>user name</td>
            <td>script id</td>
            <td>cron format</td>
        </thead>
        <tbody ng-repeat="row in data">
            <tr ng-repeat="(script_id, cron_format) in row">
                <td>{{user_id}}</td>
                <td>{{script_id}}</td>
                <td>{{cron_format}}</td>
            </tr>
        </tbody>
    </table>

试图在数据和行中做同样的事情,但它没有工作,因为我有行变量....请问有什么解决办法吗?

您非常接近 - tbody 元素中的 ng-repeat 指令应如下所示:

<tbody ng-repeat="(user_id, row) in data">

这会将您的对象中的顶级键映射到 user_id,根据您的问题,我认为这就是您想要的。