[英]select top item with ion-infinite-scroll in ionic framework
I have 我有
<ion-content bg-dark class="has-subheader has-footer has-tabs"> <div class="list active"> <div class="item item-divider" ng-repeat="item in controller.list" align="center" > <h2 class="default" ng-click="controller.load(item.a,item.b)" ng-class="{'selected':item.b==controller.b}" align="center">{{item.b}}</h2> </div> </div> <ion-infinite-scroll ng-if="!controller.noMoreItemsAvailable" on-infinite="controller.load()" distance="5%"></ion-infinite-scroll> </ion-content>
and my .css file is 而我的.css文件是
.selected{ color:black !important; } .default{ color:#7b7a7a; }
i need to select the third item from the top when i scroll and make that item as active and also i need to know how to get that item in controller 当我滚动并使该项目成为活动状态时,我需要从顶部选择第三个项目,并且我还需要知道如何在控制器中获取该项目
i tried using 我尝试使用
$ionicScrollDelegate.getScrollPosition().top; $ ionicScrollDelegate.getScrollPosition()。top;
but its not working!!! 但它不起作用!!!
the above image shows what i needed when scrolling. 上图显示了滚动时需要的内容。
You will have to select it when the list loads, saving it in your scope variable listenCtrl.b
. 列表加载时必须选择它,并将其保存在作用域变量
listenCtrl.b
。
And maybe you are not calling your scope correctly in that case, I'm guessing you are using controllerAs
and accessing the scope with controller.
在这种情况下,也许您未正确调用范围,我猜您正在使用
controllerAs
并通过controllerAs
访问范围controller.
, but in the ng-class you access to listenCtrl
instead. ,但是在ng-class中,您改为访问
listenCtrl
。 Probably you have to use controller
as well. 也许您也必须使用
controller
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.