vasyabigi / angular-slick

Angular directive for slick-carousel
http://vasyabigi.github.io/angular-slick/
MIT License
500 stars 237 forks source link

Reinitialize the carousel #133

Open nidzovito opened 8 years ago

nidzovito commented 8 years ago

<slick id="propertySlider" next-arrow=".content-next" prev-arrow=".content-prev" draggable="false" slides-to-show="1" slides-to-scroll="1" swipe="false" data="panel.properties" class="slider" init-onload=false lazy-load='ondemand'

  <div class="property-item" ng-repeat="property in panel.properties">
 </div>

I have slick code like this and panel.properties are changing later, it will include more arrays. And it doesn't regenerate the carousel, how should I regenerate it?

carinafu commented 8 years ago

I have the same issue

Alan-Penkar commented 8 years ago

I have this issue as well.

ivanmayes commented 8 years ago

+1

phazei commented 8 years ago

+1 Same here

phazei commented 8 years ago

Is there anyway to add a watch data option that will cause it to reload on change? It would need to have a watch, watchDeep, and maybe a , watchCollection option for it. Or a watch-data and watch-type

phazei commented 8 years ago

Wait, there is a watch on the data option. Just found it when looking at the code, seemd you need to initOnload to use it

        if (scope.initOnload) {
          isInitialized = false;
          return scope.$watch('data', function (newVal, oldVal) {
            if (newVal != null) {
              if (isInitialized) {
                destroySlick();
              }
              initializeSlick();
              return isInitialized = true;
            }
          });
        } else {
          return initializeSlick();
        }
<slick data="panel.properties" init-onload="true">
ipatiev commented 7 years ago

can u replace watch to watchCollection in https://github.com/vasyabigi/angular-slick/blob/master/dist/slick.js#L147 ? This callback is not triggered if you remove an element from collection by splice for example.