smart-table Angular module unable to sort

我们两清 提交于 2019-12-12 22:06:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!