获取角度ui网格滚动事件 [英] Getting angular ui grid scroll event
本文介绍了获取角度ui网格滚动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试注册到滚动事件(出现新行时得到通知),如下所示:
I am trying to register to the scroll event (get notified when new rows appear) like this:
$scope.$on('ngGridEventRows', function (event, rows) {
console.log("Scroll")
});
但是它不会触发..(角度ui-grid版本:v3.0.6)
But it does not fire.. (angular ui-grid version: v3.0.6)
实现它的正确方法是什么?
What would be the correct way to achieve it?
推荐答案
我不确定它们的本机事件,但是您可以为其滚动事件创建自己的观察程序.
Im not sure about their native events, but you could create your own watcher for their scrolling-event.
在此 Plunkr 中,我制作了一个可以滚动播放的观察器.
In this Plunkr I made a watcher that broadcasts on scroll.
$scope.gridOptions.onRegisterApi = function(gridApi){
$scope.gridApi = gridApi;
$scope.$watch('gridApi.grid.isScrollingVertically', watchFunc);
function watchFunc(newData) {
if(newData === true) {
$rootScope.$broadcast('scrolled');
}
}
};
还有你的接收者
app.controller('SecondCtrl', ['$scope', function ($scope){
$scope.$on('scrolled', function(event, args) {
console.log('was scrolled');
});
}]);
Plunkr是根据其网格滚动教程创建的.
Plunkr was created from their Grid Scrolling tutorial.
这篇关于获取角度ui网格滚动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文