我在我的智能表格中使用了st-sort指令来对所有列进行排序。当用户点击某一列时,如何获取当前排序的列?有什么技巧还是必须监听这些列标题的点击事件?
我在我的智能表格中使用了st-sort指令来对所有列进行排序。当用户点击某一列时,如何获取当前排序的列?有什么技巧还是必须监听这些列标题的点击事件?
<table st-table="displayedCollection" st-safe-src="rowCollection" st-pipe="customPipe">
$scope.customPipe = function(tableState){
console.log(tableState.sort);
}
module.directive('stSentinel',function (){
return{
require:'^stTable',
scope:{
onChange:'&stSentinel'
},
link:function(scope, element, attr, stTable){
scope.$watch(function(){
return stTable.tableState();
},function (newVal){
scope.onChange(newVal);
},
true)}
}
};
});
<table st-table="foo" st-sentinel="myCtrl.applyChange(tableState)"> ... </table>
您的控制器将定义applyChange方法来响应更改。