问题
I am unable to do a simple sort for my Smart Table Angular module. Shouldn't I just be able to add st-sort="propertyName"
to my th
?
JS:
var app = angular.module('app', []);
app.controller('SomeController', ['$scope', function($scope) {
$scope.items = [{color:'red'},{color:'blue'}];
}]);
Html:
<html ng-app="app"><body ng-controller="SomeController">
<table st-table="items">
<thead>
<tr>
<th st-sort="color">Color</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td>{{item.color}}</td>
</tr>
</tbody>
</table>
</body></html>
If you click the Colors
th
, nothing happens and the data does not sort. What am I missing? Live demo here: http://jsbin.com/ganine/2/edit
回答1:
You should add a smart-table
module dependency to you app
module like this:
var app = angular.module('app', ['smart-table']);
See working example.
回答2:
You need to load the smart-table script and add the 'smart-table'
module reference to your app
module definition.
var app = angular.module('app', ['smart-table']);
You can see my changes in jsbin - http://jsbin.com/bunokerife/3/edit
来源:https://stackoverflow.com/questions/28772706/smart-table-angular-module-unable-to-sort