1、ion-view中显示数据的代码
....
ng-if="!noMoreItemsAvailable" icon="ion-loading-d" on-infinite="loadMore()" distance="5%">
2、controller中实现动态加载数据
$scope.noMoreItemsAvailable = false;
var len = 0;
$scope.loadMore = function() {
var loadLenth = len;
if ($scope.switchCache.length - len < 12) {
len += $scope.switchCache.length - len;
} else {
len += 12;
}
if ($scope.items.length < $scope.switchCache.length) {
for (var i = loadLenth; i < len; i++) {
$scope.items.push({
id: $scope.switchCache[i].signalid, signalname:
$scope.switchCache[i].signalname, value: $scope.switchCache[i].value });
}
}
// console.log("len: " + len);
if ($scope.items.length == $scope.switchCache.length) {
$scope.noMoreItemsAvailable = true;
}
$scope.$broadcast('scroll.infiniteScrollComplete');
};
//返回list顶部
$scope.scrollMainToTop = function() {
$ionicScrollDelegate.scrollTop();
}