AngularJS无限滚动问题

问题描述:

我试图使用无限滚动来延迟加载图像。我收到以下错误,当它被称为虽然:AngularJS无限滚动问题

类型错误:未定义是不是在处理程序(http://onfilm.us/ng-infinite-scroll.js:31:34)函数

这里是什么我迄今非常冲淡了的样子。

function tagsController($scope) { 
    $scope.handleClick = function(tags) { 
     // Parse Tags 
     $scope.finished_tags = parsed_data; 
    }; 

    $scope.$emit('handleEmit', { tags = $scope.finished_tags; }); 
}; 

function imagesController($scope,$http) { 

    var rows_per = 5; 

    $scope.$on('handleBroadcast', function(event, args) { 
     // Sort the images here, put them in matrix 
     // Example: matrix[row_number] = { picture1, picture2, picture3 } 

     $scope.data = matrix; 
     $scope.loadMore(); 
    }; 

    $scope.loadMore() = function() { 
     var last = $scope.images.length; 

     for (var i = 0; i < rows_per; i++) { 
      $scope.images[last + i] = new Array(); 
      $scope.images[last + i] = $scope.data[last + i].slice(0); 
     } 
    } 
} 

粗糙的想法是,页面加载在第一时间(W /无标签),并从一个PHP脚本的图像。他们全部。它们被存储,并调用loadMore(),它将用5行图像填充$ scope.images。它确实,并且他们被加载。

该脚本中的行正在访问$ window.height和$ window.scrollup。我仍然很喜欢绿色的Javascript,所以如果我正在做一些可怕的错误,请随时声讨我。

这是破的版本我与测试: http://onfilm.us/test.html

这里是一个版本之前的延迟加载开始实施,如果看到标签的工作将如何帮助。尽管如此,我认为这不是问题。

http://onfilm.us/image_index.html

编辑:我认为这是一个问题瓦特/ NG-无限scroll.js脚本。错误在第31行(版本1.0.0)。它告诉我: TypeError:undefined不是函数 它不喜欢$ window显然。

我的JS功夫没有真正的装备来说明原因。 YOu可以从这里的简单演示中看到文字复制/粘贴作业(带有错误)onfilm.us/scroll2.html

通过引用您的网站,您的HTML标记在第一个实例中显示为不合适。您应该将无限滚动移动到ng-repeat指令的父项,以便它不会针对生成的每一行进行重叠调用。请访问http://binarymuse.github.io/ngInfiniteScroll/demo_basic.html

+0

感谢您的意见。我已经更新了onfilm.us/test.html,但得到同样的问题 - 在无限scroll.js内的错误。我将尝试实现简单的演示,并从那里“建立”。 – 2014-10-17 14:47:59

+0

我已经基本上复制/粘贴简单的演示,并得到相同的错误。请查看onfilm.us/scroll.html。我从主站点下载了1.0.0。 – 2014-10-17 18:36:31

+2

嘿,你缺少JQuery的lib参考。请注意,Angular只提供了基本的JQuery功能,这不适用于无限滚动。在角度参考之前添加此项。此外,在你的loadMore fn - $ scope.imges中有一个拼写错误,而不是$ scope.images – Amitesh 2014-10-20 06:38:32