使用ng-repeat将数组索引到AngularJS中的列中

时间:2016-08-25 12:07:31

标签: angularjs angularjs-ng-repeat

我需要帮助使用AngularJS ng-repeat将JSON数组索引放入表列中。下面是JSON,我想将其转换为HTML表格:

{
  "Employee": [
    {
      "Name": "`Rocky`",
      "Location": "Office"
    },
    {
      "Name": "John",
      "Location": "Home"
    }
  ]
}
<table>
    <tbody>
        <tr>
            <td>Rocky</td>
            <td>John</td>
        </tr>
        <tr>
            <td>Office</td>
            <td>Home</td>
        </tr>
    </tbody>
</table>

3 个答案:

答案 0 :(得分:1)

就这样使用:

SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'your_database_here' AND TABLE_NAME LIKE '%letters_from_your_table_here%' ORDER BY TABLE_NAME DESC

答案 1 :(得分:1)

你可以这样做:

<table>
  <tbody>
      <tr ng-repeat="list in object.Employee">
          <td>{{list.Name}}</td>
          <td>{{list.Location}}</td>
      </tr>
  </tbody>
</table>

http://jsfiddle.net/Lvc0u55v/8699/

答案 2 :(得分:0)

要使用ng-repeat访问数组键,请执行以下操作:

<tr ng-repeat="item in obj.EmpArray">
    <td>{{item.Name}}</td>
    <td>{{item.Location}}</td> 
</tr>