Angularjs 滾動加載更多數(shù)據(jù)
來源:易賢網(wǎng) 閱讀:1688 次 日期:2016-07-19 15:38:27
溫馨提示:易賢網(wǎng)小編為您整理了“Angularjs 滾動加載更多數(shù)據(jù)”,方便廣大網(wǎng)友查閱!

下面的例子只是為了簡單記錄怎么使用angularjs來實(shí)現(xiàn)滾動加載數(shù)據(jù),具體的還是需要具體看待:

Javascript部分的controller

app.controller('AnalysizerCtrl', ['$scope', '$timeout', '$window',

function ($scope, $timeout, $window) {

$scope.showData = false;

$scope.isLoadingPIG = false;

$scope.isLoadingUJ = false;

$scope.isLoadingBoxSummary = false;

$scope.LoadingData = function (index) {

$scope.showData = true;

var pigHeight = $(".analysisContainer")[1].children[1].scrollHeight;

var ujHeight = $(".analysisContainer")[1].children[2].scrollHeight;

var boxSummaryHeight = $(".analysisContainer")[1].children[3].scrollHeight;

if (index == 0) {

//$scope.reLoadData = true;

pigHeight = 0;

ujHeight = 0;

$scope.gridOptions.data = null;

}

var showSummaryBox = function () {

$scope.isLoadingBoxSummary = false;

}

var showUj = function () {

$scope.isLoadingUJ = false;

//$scope.isLoadingSummaryBox = true;

//$timeout(showSummaryBox, 1000);

}

var showPig = function () {

$scope.isLoadingPIG = false;

//$scope.isLoadingUJ = false;

//$timeout(showUj, 10000);

}

if (pigHeight == 0) {

$scope.isLoadingPIG = true;

$timeout(showPig, 1000);

} else if (ujHeight == 0) {

$scope.isLoadingUJ = true;

$timeout(showUj, 1000);

} else if (boxSummaryHeight == 0) {

$scope.isLoadingBoxSummary = true;

$timeout(showSummaryBox, 1000);

}

};

}]

).directive('whenScrollEnd', function () {

return function (scope, elm, attr) {

var pageWindow = $(this);

pageWindow.bind('scroll', function (et, ed, pb) {

var winScrollTop = pageWindow.scrollTop();

var winHeight = pageWindow.height();

var maxScrollHeight = $(".analysisContainer")[1].scrollHeight;

if ((winScrollTop + winHeight) > maxScrollHeight) {

scope.$apply(attr.whenScrollEnd);

}

});

}

});

下面是HTML部分:

<div class="analysisContainer" ng-show="showData" when-scroll-end="LoadingData()">

<div id="b" ng-show="isLoadingPIG" style="width: 100%; text-align: center; z-index: 1">

<h6 class="loading">

<img src="~/Content/Images/loading2.gif" />

Loading Win & Convert data...

</h6>

</div>

<div id="a" ng-show="!isLoadingPIG">

<img src="~/2016-03-16_152323.png" />

</div>

<div ng-show="!isLoadingUJ">

<img src="~/2016-03-16_153347.png" />

</div>

<div ng-show="!isLoadingBoxSummary">

<img src="~/2016-03-16_153404.png" />

</div>

</div>

重要的部分是指令(directive)和滾動時(shí)要加載數(shù)據(jù)的部分。

Angularjs 滾動加載更多數(shù)據(jù)的相關(guān)知識,小編就給大家介紹這么多,希望對大家有所幫助!

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:Angularjs 滾動加載更多數(shù)據(jù)
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)