Ng-repeat on ion-slide


#1

i have a problem with ng-repeat and ion-slide.

here is my code

<ion-slide-box does-continue="true" auto-play="true" show-pager="false" on-slide-changed="slideHasChanged($index)">
	<ion-slide ng-click="goToNoti()" ng-repeat="item in items">
		<div class="box" >
			<a class="item" href="#">
				{{item.notiSubject}}
				<span class="badge badge-assertive">{{item.notiType}}</span>
			</a>
		</div>
	</ion-slide>
</ion-slide-box>

i’m pulling data from a server and try to make multiple <ion-slide>.

if i console the data it works fine, but somehow the console.log performs twice,
then in a few seconds, i get “Uncaught TypeError: Cannot read property ‘length’ of undefined” error

so i tried $ionicLoading and $timeout to buy some time to get data fully loaded. But this didn’t work either.

please help me,

thank you


#2

Solved the “Uncaught TypeError” by adding $ionicSlideBoxDelegate.update();

Thank you


#3

The problem is, that you set autoplay but your array is undefined when the slidebox is initialised.

So slidebox wants to start sliding, but there is no list.

you could even add an ng-if to the slidebox:

<ion-slide-box does-continue="true" ng-if="items.length" auto-play="true" show-pager="false" on-slide-changed="slideHasChanged($index)">