【发布时间】:2015-07-10 08:27:45
【问题描述】:
我在向我的 HTML 中的表格添加行时遇到问题,该表格来自一个包含对象的数组。
当我运行我的代码时,我会像这样发出$get 请求:
var app = angular.module('TM', []);
app.controller('tableController', function($http){
this.protocolList = [];
// Initialise array
$http.get('../protocols').success(function(data) {
console.log('Success ' + data);
this.protocolList = data;
angular.forEach(this.protocolList, function(value, key) {
console.log(key + ': ' + value.id + ' - ' + value.name);
});
})
.error(function(){
console.log('Error ' + data)
});
});
当我打开网络浏览器时,我看到以下内容:
当我尝试将其添加到我的 HTML 文件中的表格时,我的问题发生了:
<table class="table table-striped">
<thead>
<tr>
<th ng-repeat="c in tctrl.currentDataObject.tableColumns"> {{ c }} </th>
</tr>
</thead>
<!-- This does not ouput anything...-->
<tbody>
<tr ng-repeat="(key, value) in tctrl.protocolList">
<td> {{ value }} </td>
</tr>
</tbody>
</table>
任何帮助将不胜感激。
【问题讨论】:
-
HTML 文件中是如何引用 tableController 的?
标签: html angularjs get angularjs-ng-repeat