Hi folks, while testing ionic on the Desktop (either using ionic serve or via electron), I’ve noticed in one of my screens, which is basically a long collection-repeat of events, mouse-wheeling does not work with scrolling - it scrolls a few steps and stops. This is not the case in other screens and I’ve tested other codepen collection-repeats and they work with the mouse-wheel.
Can someone suggest what may be causing the issue with my template?
thanks
Okay, if I switch to ng-repeat there is no scrolling wheel problem.
I don’t want to switch to ng-repeat for devices, but for desktop its fine.
Is there a way to do a ternary operator what switches between ng-repeat or collection repeat? I currently have this, which I don’t like:
<div ng-if="$root.platformOS=='desktop'">
<ion-item ng-repeat="event in events| filter:search.text" item-height="event.Event.height" id="item-{{$index}}">
</div>
<div ng-if="$root.platformOS!='desktop'">
<ion-item collection-repeat="event in events| filter:search.text" item-height="event.Event.height" id="item-{{$index}}">
</div>
The final solution I used solved this very elegantly. (Thanks to stackoverflow)
//------------------------------------------------------------------
// switch between collection repeat or ng-repeat
//-------------------------------------------------------------------
.directive('repeat', function ($compile, $rootScope) {
return {
restrict: 'A',
priority: 2000,
terminal: true,
link: function (scope, element) {
var repeatDirective = ($rootScope.platformOS == 'desktop') ? 'ng-repeat' : 'collection-repeat';
//console.log ("*********** REPEAT SCROLL IS " + repeatDirective);
element.attr(repeatDirective, element.attr('repeat'));
element.removeAttr('repeat');
$compile(element)(scope);
}
};
})