Вопрос

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?

Это было полезно?

Решение

Template:

<ion-slide-box active-slide="myActiveSlide">

Controller:

$scope.myActiveSlide = index;

Другие советы

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);
};
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top