Closed bknill closed 7 years ago
Yes that should work.
But if you only want to select the fourth item automatically at start you have the 'selectAtStart' property in the options. You could set it like this:
selectAtStart { property : 'id', value:yourArray[3].id }
Thanks.. Actually that might be a better idea. Do you know if this data gets updated when the $scope.$broadcast('a-carousel.arrayupdated', 'carousel-1'); gets' called?
There are 2 situations, when I'm starting and want to pre-select an item, and when this is getting called at a later time because the data updated and the item is then deselected.
Yes it should work.
Although I just realize that the doc is incomplete. You can send the event 'a-carousel.arrayupdated' with an option object (the same as when initiating the carousel) instead of the carouselId.
Important: you must add a "carouselId" property in the option object
So you can do
var carouselOptions = {
carouselId : 'carousel-1',
selectAtStart : {
property : 'id',
value: 123
}
... all other options of your carousel
}
$scope.$broadcast('a-carousel.arrayupdated', carouselOptions);
I can see a method to deselect an item, is there one to select an item? (i.e. I want to automatically select the second item rather than the first)
If not I can see how I'd add it I think - just add a new listener with the id and call selectItem(id) right!?