gpt4 book ai didi

javascript - 多重 ionic 卷轴,无限卷轴

转载 作者:数据小太阳 更新时间:2023-10-29 05:32:42 27 4
gpt4 key购买 nike

我有两个 ionic 滚动标签。在每个 ion-scroll 标签中都有一个列表。这些列表中的每一个都以 10 个项目开始,当用户到达特定 ionic 卷轴的底部时,它应该加载更多。我面临的问题是这无法正常工作。如果我滚动第一个滚动窗口并对所有项目进行分页,它应该不会再显示任何内容。但这并没有发生,相反,如果我滚动第二个滚动窗口,那么它将在第一个和第二个 ionic 滚动窗口(我不想要)中加载更多项目。本质上我希望两个 ionic 卷轴完全独立。我希望每个人都加载自己的内容。我希望这是有道理的。这是我的代码笔:

http://codepen.io/polska03/pen/jWKRwP

HTML:

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

<title>Ionic Pull to Refresh</title>

<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

</head>
<body ng-app="ionicApp" ng-controller="MyCtrl" class="background-places">

<ion-view>
<ion-content class="" scroll='false'>
<ion-scroll style="height:50%">
<ion-list>
<ion-item collection-repeat="list in _list">
<h2>Item</h2>
</ion-item>
</ion-list>
<button class="button button-full button-outline button-positive" ng-if="noMoreContent">
No more Content
</button>
<ion-infinite-scroll ng-if="canWeLoadMoreContent()" on-infinite="populateList()" distance="1%">
</ion-infinite-scroll>
</ion-scroll>

<hr>
<hr>

<ion-scroll style="height:50%">
<ion-list>
<ion-item collection-repeat="list2 in _list2">

<h2>Item</h2>

</ion-item>
</ion-list>



<button class="button button-full button-outline button-positive" ng-if="noMoreContent2">
No More Content
</button>
<ion-infinite-scroll ng-if="canWeLoadMoreContent2()" on-infinite="populateList2()" distance="1%">
</ion-infinite-scroll>
</ion-scroll>

</ion-content>

</ion-view>


</body>
</html>

Javascript:

angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {






$scope._list = [];

$scope.populateList = function() {
for (var i = 0; i <= 9; i++) {


$scope._list.push({});
}
console.log($scope._list.length);
$scope.$broadcast('scroll.infiniteScrollComplete');
}

$scope.noMoreContent = false;

$scope.canWeLoadMoreContent = function() {
if($scope._list.length > 15) {
$scope.noMoreContent = true;

return false;
}else{
return true;
}
}
$scope.populateList();





$scope._list2 = [];

$scope.populateList2 = function() {
for (var i = 0; i <= 9; i++) {



$scope._list2.push({});

}
console.log($scope._list2.length);
$scope.$broadcast('scroll.infiniteScrollComplete');
}

$scope.noMoreContent2 = false;

$scope.canWeLoadMoreContent2 = function() {
if($scope._list2.length > 15) {
$scope.noMoreContent2 = true;

return false;
}else{
return true;
}
}



$scope.populateList2();




});

最佳答案

问题来自指令中未正确解决的'require' ?^ionicScroll。不知道为什么,因为我不是 AngularJS 专家。也就是说,我找到了一种解决方法,即在内容标签周围插入一个额外的 div,如 http://codepen.io/priand/pen/PzYbZG 中所示。 ,如果这对某人有帮助。

<div>
<ion-content class="has-header col col-50">
<ion-list>
<ion-item ng-repeat="item in items"
item="item">
Item {{ item.id }}
</ion-item>
</ion-list>
<ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="10%"></ion-infinite-scroll>
</ion-content>
</div>

<div>
<ion-content class="has-header col col-offset-50 col-50">
<ion-list>
<ion-item ng-repeat="item in items2"
item="item">
Item {{ item.id }}
</ion-item>
</ion-list>
<ion-infinite-scroll ng-if="!noMoreItemsAvailable2" on-infinite="loadMore2()" distance="10%"></ion-infinite-scroll>
</ion-content>
</div>

关于javascript - 多重 ionic 卷轴,无限卷轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35140875/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com