我試圖使用無限滾動來延遲加載圖像。我收到以下錯誤,當它被稱爲雖然: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
感謝您的意見。我已經更新了onfilm.us/test.html,但得到同樣的問題 - 在無限scroll.js內的錯誤。我將嘗試實現簡單的演示,並從那裏「建立」。 – 2014-10-17 14:47:59
我已經基本上覆制/粘貼簡單的演示,並得到相同的錯誤。請查看onfilm.us/scroll.html。我從主站點下載了1.0.0。 – 2014-10-17 18:36:31
嘿,你缺少JQuery的lib參考。請注意,Angular只提供了基本的JQuery功能,這不適用於無限滾動。在角度參考之前添加此項。此外,在你的loadMore fn - $ scope.imges中有一個拼寫錯誤,而不是$ scope.images – Amitesh 2014-10-20 06:38:32