devmark / angular-slick-carousel

Angular directive for slick-carousel
http://devmark.github.io/angular-slick-carousel/
MIT License
353 stars 125 forks source link

Dynamic configurations #117

Closed kenkogi closed 7 years ago

kenkogi commented 7 years ago

I'm trying to have dynamic configs but this doesn't seem to work. I'm making an ajax call to get my settings then assigning value to my slick carousel settings. Something like below.

$scope.configs = {
  slidesToShow: dataFromAjax
}

In my html I have the expected

<slick settings="configs" ng-if="ajaxDataLoaded">
  <li>My list of items</li>
</slick>

The data from my ajax call never seems to take effect. Any ideas how to fix this?

kenkogi commented 7 years ago

I just found the solution and figured someone could use this. Right before setting ajaxDataLoaded to true I assign the new configuration.

$timeout ( function() {
  $scope.configs.slidesToShow = dataFromAjax;
  $scope.ajaxDataLoaded = true;
}, 0);

This seems to fix the issue.