Javascript 使用角度数据表显示JSON数据

Javascript 使用角度数据表显示JSON数据,javascript,angularjs,json,datatables,angular-datatables,Javascript,Angularjs,Json,Datatables,Angular Datatables,我使用Angular DataTable使用JSON数组显示数据,但数据没有显示。我认为我的HTML页面有问题。你能找到问题所在吗 HTML文件: <tbody> <tr ng-repeat="user in userList"> <td><a class="green shortinfo" href="javascript:;" ng-click="childInfo(user, $event)" title="Click to vi

我使用Angular DataTable使用JSON数组显示数据,但数据没有显示。我认为我的HTML页面有问题。你能找到问题所在吗

HTML文件:

   <tbody>
  <tr ng-repeat="user in userList">
    <td><a class="green shortinfo" href="javascript:;" ng-click="childInfo(user, $event)" title="Click to view more"><i class="glyphicon glyphicon-plus-sign"></a></td>
    <td>{{user.name}}</td>
    <td>{{user.position}}</td>
    <td>{{user.office}}</td>
    <td><div class="btn-group">
            <button type="button" class="btn btn-default btn" ng-click="edit($index);"><i class="glyphicon glyphicon-pencil"></i></button>  
            <button type="button" class="btn btn-default btn" ng-click="delete();"><i class="glyphicon glyphicon-trash"></i></button> 
            </div></td>
  </tr>
</tbody>
]);
}您的JSON无效,请将其更改为

{
  "InvoiceHeaders": [
    {
      "name": "Tiger Nixon",
      "position": "System Architect",
      "salary": "$320,800",
      "start_date": "2011/04/25",
      "office": "Edinburgh",
      "extn": "5421"
    },
    {
      "name": "Garrett Winters",
      "position": "Accountant",
      "salary": "$170,750",
      "start_date": "2011/07/25",
      "office": "Tokyo",
      "extn": "8422"
    }
  ]
}
演示

var myApp=angular.module('testApp',[]);
myApp.controller('myCtrl',函数($scope){
$scope.userList={
“发票抬头”:[
{
“名字”:“老虎尼克松”,
“职位”:“系统架构师”,
“工资”:“$320800”,
“开始日期”:“2011/04/25”,
“办公室”:“爱丁堡”,
“extn”:“5421”
},
{
“姓名”:“Garrett Winters”,
“职位”:“会计”,
“工资”:“$170750”,
“开始日期”:“2011/07/25”,
“办公室”:“东京”,
“extn”:“8422”
}
]
}
});

  • {{user.name}
  • {{user.position}
  • {{user.office}

您的问题是userList实际上不是一个或多个用户,而是一个JS对象,具有一个名为InvoiceHeaders的属性,其值是一个用户列表?我正在尝试将datatable示例用于我的项目。请尝试设置$scope.userList=[{“name”:“Tiger”,…},{“name”:“Garret”,…}]。。。复制并粘贴您的JSON代码到,您应该删除尾随;之后]
{
  "InvoiceHeaders": [
    {
      "name": "Tiger Nixon",
      "position": "System Architect",
      "salary": "$320,800",
      "start_date": "2011/04/25",
      "office": "Edinburgh",
      "extn": "5421"
    },
    {
      "name": "Garrett Winters",
      "position": "Accountant",
      "salary": "$170,750",
      "start_date": "2011/07/25",
      "office": "Tokyo",
      "extn": "8422"
    }
  ]
}