1
我想將項目滾動到屏幕頂部。當按下該項目時。我正在使用以下代碼。
<ion-list id="iphoneTutorials-list2" ng-repeat="(f,chapter) in iphoneVideos">
<ion-item style="border-left: none;border-right: none;border-top: none;" class="item-text-wrap" ng-click="toggledisplay($index)" delegate-handle="$index"><i class="icon ion-ios-arrow-right" ng-if="!trigger[$index]"></i>
<i class="icon ion-ios-arrow-down" ng-if="trigger[$index]"></i> {{chapter.chapter_name}}</ion-item>
<ion-list ng-show="trigger[$index]">
<ion-item class="item-text-wrap" ng-click="openVideo(video.video_id,video.video_name,f,$index,video.Description)" style="margin-left: 10%;border-left: none;border-right: none;" ng-repeat="video in chapter.chapter_content">{{video.video_name}}</ion-item>
</ion-list>
和控制器我使用這個:
$rootScope.toggledisplay = function(index){
$timeout($ionicScrollDelegate.$getByHandle(index).scrollTop(),3000);
if($rootScope.trigger[index]){
$rootScope.trigger[index] = false;
}
else{
$rootScope.trigger[index] = true;
}
}
此
消息我收到的控制檯:
ionic.bundle.js:26799 Delegate for handle "7" could not find a corresponding element with delegate-handle="7"! scrollTop() was not called!
Possible cause: If you are calling scrollTop() immediately, and your element with delegate-handle="7" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to scrollTop() and try again.
任何可以幫助我與我的問題?
這是離子的V1正確執行呢? –