2015-11-20 22 views

回答

4

你可以使用指令st-pipe,這個函數將被調用來排序,分頁或過濾事件。

<table st-table="displayedCollection" st-safe-src="rowCollection" st-pipe="customPipe"> 

$scope.customPipe = function(tableState){ 
    console.log(tableState.sort); 
} 
+0

一個問題。 customPipe函數在我的情況下被成功調用。但這個集合沒有顯示在我的智能表中。當我刪除st管道時,我可以看到集合。 – yalkris

+0

我爲st-pipe的顯示問題創建了一個單獨的問題。 http://stackoverflow.com/questions/34161735/st-pipe-causing-display-issue – yalkris

2

我認爲,這將給你最好的控制技術將是創建一個插件,將腕錶在表中的狀態變化,並會調用只要檢測到變化的提供的回調(在你的情況,你將支付特別要注意的遊戲桌狀態

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方法反應變化

+0

我的ctrl函數給出了一個錯誤,tableState是未定義的。 「TypeError:無法讀取未定義屬性」排序「。 – yalkris

+0

更改爲scope.onChange({tableState:newVal})正在工作 –

相關問題