sebelga / ionic-advanced-carousel

Carousel directive for Ionic Frameworks that allows any custom template as an item.
http://sebelga.github.io/ionic-advanced-carousel/
GNU General Public License v2.0
42 stars 18 forks source link

Carousel inside repeater #3

Closed guilhermevini closed 8 years ago

guilhermevini commented 8 years ago

I have a collection of shows. Each show have a collection of episodes.

<div ng-repeat="show in shows">
<a-carousel carousel-options="" array-provider="show.Episodes"  on-select="goEpisodeCarousel( item )"></a-carousel>
</div>

I need to put a ID into each carrousel, but i can make a lot of option object. The perfect case for me:

<a-carousel carousel-ID="show.ID" carousel-options="episodeDefaultOption" array-provider="show.Episodes" on-select="goEpisodeCarousel( item )"></a-carousel>

I need this carousel-ID because, a-carousel.arrayupdated broadcast requide a carousel Id. its possible?

sebelga commented 8 years ago

Hello, You are right, it would be better to have the carousel id outside of the options. I will make the change this week-end.

For now you can try this:

Import the src file 'advanced-carousel.js' in your html instead of the .min.js and change:

bindToController with:

bindToController: {
    itemDirective  : '@',
    carouselOptions: '=',
    arrayProvider  : '=',
    onSelect       : '&',
    carouselId     : '@?'
}

update the lines in activate() function with:

function activate() {
    angular.extend(vm.options, vm.carouselOptions);
    if (vm.carouselId) {
        vm.options.carouselId = vm.carouselId
    }
    // ...  rest of the function

Then you should be able to pass the carousel-id like you mentioned

<a-carousel carousel-id="show.ID" carousel-options="episodeDefaultOption" array-provider="show.Episodes" on-select="goEpisodeCarousel( item )"></a-carousel>

I haven't tested it so tell me if it works :)

guilhermevini commented 8 years ago

After change

[INFO] Creating Carousel but DOM not ready yet...

sebelga commented 8 years ago

Hi, I updated the carousel to version 1.1.1 Try it, it should work now inside a ng-repeat. Tell me if you have any problem with it.