Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将spyMargin与ng scrollable一起使用_Javascript_Angularjs - Fatal编程技术网

Javascript 如何将spyMargin与ng scrollable一起使用

Javascript 如何将spyMargin与ng scrollable一起使用,javascript,angularjs,Javascript,Angularjs,我在uib popover中使用ng scrollable指令。 我想使用spyMargin设置,以便在滚动条到达某个点时能够加载更多的项目,就像facebook在其通知中所做的那样 以下是我使用指令的方式: <div class="scrollable-container" ng-scrollable="{scrollX:'none',scrollY:'right', spyMargin: 0.75}"> 然而,没有任何东西被输出到控制台,所以很明显我做错了什么。以下是ng可滚动

我在uib popover中使用ng scrollable指令。 我想使用spyMargin设置,以便在滚动条到达某个点时能够加载更多的项目,就像facebook在其通知中所做的那样

以下是我使用指令的方式:

<div class="scrollable-container" ng-scrollable="{scrollX:'none',scrollY:'right', spyMargin: 0.75}">
然而,没有任何东西被输出到控制台,所以很明显我做错了什么。以下是ng可滚动主页的链接:


我还创建了一个plnkr来说明这是如何工作的:

好吧,你做得很好。问题在于它本身。我检查了源代码,发现库中有很多模式错误和错误的AngularJS行为。问题在于AngularJS指令的孤立作用域行为。请看一下这里,我修复了错误的
$broadcasting
处理
ng scrollable
。查看文件
ng scrollable.min.js
264到274

这将对您有效,但最好在上发出拉取请求


@托莫·布莱恩干杯(m8=)
$scope.$on('scrollable.spybottom', function (e, contentTop, id) {
    console.log("Near the bottom!");
});
// fire scrollSpy events only when entering a margin
if (contentTop < containerHeight * config.spyMargin && oldTop >= containerHeight * config.spyMargin) {
  $scope.$emit('scrollable.spytop', contentTop, config.id);
}
if (contentTop > contentHeight - containerHeight * (config.spyMargin + 1) && oldTop <= contentHeight - containerHeight * (config.spyMargin + 1)) {
  $scope.$emit('scrollable.spybottom', contentTop, config.id);
}
if (contentLeft < containerWidth * config.spyMargin && oldLeft >= containerWidth * config.spyMargin) {
  $scope.$emit('scrollable.spyleft', contentLeft, config.id);
}
if (contentLeft > contentWidth - containerWidth * (config.spyMargin + 1) && oldLeft <= contentWidth - containerWidth * (config.spyMargin + 1)) {
  $scope.$emit('scrollable.spyright', contentLeft, config.id);
}
// Code goes here
var myModule = angular.module('myModule', ["ui.bootstrap", "ngScrollable"]);

myModule.controller('myController', function($scope, $rootScope, $timeout) {

    //we listen here to see if the scroll-bar spybottom is working
    $scope.$on('scrollable.spybottom', function (e, contentTop, id) {
        console.log("Near the bottom!");
    }); 
});