Reputation: 3272
I try to get the ion-slide-box start at certain index.
slidebox-controller :
$ionicSlideBoxDelegate.slide(index);
slide-box-temp :
<ion-slide ng-repeat="pic in pictures"><div>...</div></ion-slide>
This doesn't work. Maybe because the slide-box hasn't been rendered yet.
Is there another way to start the slide-box at a certain index?
Upvotes: 2
Views: 5722
Reputation: 3672
I have try using active-slide, but i had better control using this directive, to know when the ng-repeat is rendered
angular.module('starter')
.directive('repeatDone', function () {
return function (scope, element, attrs) {
if (scope.$last) { // all are rendered
scope.$eval(attrs.repeatDone);
}
}
})
HTML :
<ion-slide-box>
<ion-slide ng-repeat="day in week" repeat-done="repeatDone()" >
In your controller
$scope.repeatDone = function() {
$ionicSlideBoxDelegate.update();
$ionicSlideBoxDelegate.slide($scope.week.length - 1, 1);
};
Upvotes: 1
Reputation: 3272
Template:
<ion-slide-box active-slide="myActiveSlide">
Controller:
$scope.myActiveSlide = index;
Upvotes: 10