如何从Slick Slider中清除以前的数据?

时间:2017-07-27 07:22:02

标签: javascript jquery angularjs jquery-ui

我使用以下代码显示单击一个按钮时调用的数据。当我点击第二个按钮时,新数据会出现并显示。

/*-------SLIDER ANIMATION (START)----------*/
$scope.getBikeAds = function (reqobj) {
  var request = {
    authToken : '',
    cityName : reqobj.name ? reqobj.name : 'Bangaluru'
  };
  mainService.getBikesModels(request).then(function (success) {
    $scope.bikesAds = [];
    if (success && success.data.errorMessage == 'Success') {
      $scope.bikesAds = enlargeBikeImage(success.data.data.bikeModels);    //For 2x Image        
      $timeout(function() {
        if($('.regular2').hasClass("slick-initialized"))
          $('.regular2').slick('unslick'); 
          $(".regular2").slick({
            infinite: true,
            lazyLoad: 'ondemand',
            slidesToShow: 3,
            slidesToScroll: 1,
            variableWidth: true,
            responsive: [
              {
                breakpoint: 768,
                settings: {
                  arrows: true,
                  centerMode: true,
                  centerPadding: '40px',
                  slidesToShow: 1
                }
              },
              {
                breakpoint: 480,
                settings: {
                  arrows: true,
                  centerMode: true,
                  centerPadding: '26px',
                  slidesToShow: 1
                }
              }
            ]
          });
      },0);
    } else {
      $scope.bikesAds = [];
    }
  });
};
 /*-------SLIDER ANIMATION (END)----------*/
$scope.closeBikeAdsSlider = function() {
    $scope.bikesAds = [];
    $scope.checked = false;
    $( "#effect" ).toggle( 'scale', 500 );
    $scope.cityName = "";
};

当我点击下一个按钮时,来自上一次服务呼叫的数据正在与新数据相加。如何在光滑关闭或打开时清除以前的数据?

0 个答案:

没有答案