尝试使用angularjs中的智能表在表上设置排序
使用带有的尝试使用angularjs中的智能表在表上设置排序,angularjs,smart-table,Angularjs,Smart Table,使用带有的angularjs。已绘制表标题,但没有数据行。没有智能表格数据显示良好。有什么想法吗 控制台中出现错误 "Error: [$compile:ctreq] http://errors.angularjs.org/1.4.7/$compile/ctreq?p0=stTable&p1=stSort 数据集 [{ "name": "Robert B", "associatedNumber": 21, "standing": true }, {
angularjs
。已绘制表标题,但没有数据行。没有智能表格
数据显示良好。有什么想法吗
控制台中出现错误
"Error: [$compile:ctreq] http://errors.angularjs.org/1.4.7/$compile/ctreq?p0=stTable&p1=stSort
数据集
[{
"name": "Robert B",
"associatedNumber": 21,
"standing": true
}, {
"name": "Martin C",
"associatedNumber": 55,
"standing": true
}, {
"name": "Bobby B",
"associatedNumber": 15,
"standing": true
}]
json
由api/players
返回
var app = angular.module('lmsHome', ['smart-table']);
app.controller('lmsHomeCtrl', function ($scope, $http) {
$http.get("/players").success(function (response) {
$scope.players = response;
});
});
html
<div ng-app="lmsHome" ng-controller="lmsHomeCtrl">
<table class="table table-hover">
<thead>
<tr>
<th st-sort="name">Player</th>
<th st-sort="associatedNumber">Number</th>
<th st-sort="standing">Still standing?</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="player in players" ng-class="{'success': player.standing}">
<td ng-cloak>
<span ng-show="player.standing">
{{player.name}}
</span>
<span ng-show="!player.standing">
<strike>{{player.name}}</strike>
</span>
</td>
<td ng-cloak>{{player.associatedNumber}}</td>
<td ng-cloak>
<span class="label">{{player.standing}}</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/jquery/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/bootstrap/js/bootstrap.min.js"></script>
<!-- Angularjs -->
<script src="/angular/angular.min.js"></script>
<!-- A table/grid for Angularjs -->
<script src="/table/smart-table.min.js"></script>
<!-- Custom logic -->
<script src="/js/homeLogic.js"></script>
玩家
数
还站着吗?
{{player.name}
{{player.name}
{{player.associatedNumber}
{{玩家站着}
根据智能表格的说明,为了使用智能表格
第一件事是将模块angular.module('myApp',['smart-table']
添加到您的angular应用程序中。然后使用您通常对html表所做的标记。在table元素上添加st table
属性,告诉智能表哪个集合保存您的显示数据,(即您将在中继器中使用的一个)。现在您将能够使用插件组成表
因此,它显示为缺少st table
属性
玩家
数
还站着吗?
...
按照错误中提供的链接,找不到指令“stSort”所需的控制器“stTable!”。这会删除错误并将我的数据填充到表中,但现在当我单击表头时,所有数据都会消失。@bobbyrne01我真的不知道为什么会发生这种情况,这听起来像是另一个问题。我不知道使用Smart Table或参与它的开发,我只是查找您发布的错误并提供文档来解决它。