Angularjs ng repeat in table rows不显示行
我正试图用Angularjs设计一个动态表,我发现ng repeat函数很有用 经过一些尝试后,我不知道它是如何工作的,因为我的属性工作得很好,但我的属性没有显示任何内容 这是我的.jsAngularjs ng repeat in table rows不显示行,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,我正试图用Angularjs设计一个动态表,我发现ng repeat函数很有用 经过一些尝试后,我不知道它是如何工作的,因为我的属性工作得很好,但我的属性没有显示任何内容 这是我的.js .controller('DispatcherFilterController', [ '$scope', function($scope,{ $scope.dispatcherSearch=[{ id: 1,
.controller('DispatcherFilterController',
[ '$scope',
function($scope,{
$scope.dispatcherSearch=[{
id: 1,
name: 'out1',
description :'desc1',
vat_number :'378297',
dispatch_type :'daily',
output : 'out1'
}, {
id: 2,
name: 'out2',
description :'desc2',
vat_number :'3782f97',
dispatch_type :'daily',
output : 'out2'
},
{
id: 3,
name: 'out3',
description :'desc3',
vat_number :'fssfes',
dispatch_type :'daily',
output : 'out3'
}];}])
这是我的HTML:
<div class="table-responsive">
<table class="table" ng-controller="DispatcherFilterController">
<thead>
<tr>
<th class="col-order"><a class="sort asc" href="#" title="">{{'NAME'
| translate}}</a>
</th>
<th class="col-order"><a class="sort asc" href="#" title="">{{'DESCRIPTION'
| translate}}</a>
</th>
<th class="col-order"><a class="sort asc" href="#" title="">{{'VAT_NUMBER'
| translate}}</a>
</th>
<th class="col-order"><a class="sort asc" href="#" title="">{{'DISPATCH_TYPE'
| translate}}</a>
</th>
<th class="col-order"><a class="sort asc" href="#" title="">{{'OUTPUT'
| translate}}</a>
</th>
<th class="colf-cmd"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in dispatcherSearch">
<td>{{row.name}}</td>
<td>{{row.description}}</td>
<td>{{row.vat_number}}</td>
<td>{{row.dispatch_type}}</td>
<td>{{row.output}}</td>
<td class="colf-cmd">
<div class="form-inline pull-right">
<div class="form-group">
<div class="form-btn-container">
<button type="button" class="btn btn-primary pull-right" ng-click="spot()">{{'SPOT' | translate}}</button>
</div>
</div>
<div class="form-group">
<div class="form-btn-container">
<button type="button" class="btn btn-primary pull-right" ng-click="periodic()">{{'PERIODIC' | translate}}</button>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
{{row.name}
{{row.description}}
{{row.vat_number}
{{row.dispatch_type}
{{row.output}
{{'SPOT'| translate}
{{'PERIODIC'| translate}}
我哪里出错了?您忘了完成控制器功能 下面是更正的控制器代码 Js代码
var app = angular.module('myApp', []);
app.controller('DispatcherFilterController', ['$scope',
function($scope) {
$scope.dispatcherSearch = [{
id: 1,
name: 'out1',
description: 'desc1',
vat_number: '378297',
dispatch_type: 'daily',
output: 'out1'
}, {
id: 2,
name: 'out2',
description: 'desc2',
vat_number: '3782f97',
dispatch_type: 'daily',
output: 'out2'
}, {
id: 3,
name: 'out3',
description: 'desc3',
vat_number: 'fssfes',
dispatch_type: 'daily',
output: 'out3'
}];
}
]);
这将起作用控制器代码中存在语法错误。另外,您还没有为
translate
过滤器提供任何代码,因此我也删除了该过滤器,我们这里有一个可用的
控制器
.controller('DispatcherFilterController', ['$scope',
function($scope) {
$scope.dispatcherSearch = [{
id: 1,
name: 'out1',
description: 'desc1',
vat_number: '378297',
dispatch_type: 'daily',
output: 'out1'
}, {
id: 2,
name: 'out2',
description: 'desc2',
vat_number: '3782f97',
dispatch_type: 'daily',
output: 'out2'
}, {
id: 3,
name: 'out3',
description: 'desc3',
vat_number: 'fssfes',
dispatch_type: 'daily',
output: 'out3'
}];
}]);
有控制台错误吗?