From c631a8eff944aacb9f826a3b6b8eee0932e5355d Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 9 Feb 2015 09:40:22 -0700 Subject: [PATCH] feat(ionSlideBox): hide/show pager depending on dynamic show-pager attribute --- js/angular/directive/slideBox.js | 20 ++++++++++++++------ test/html/slideBox.html | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/angular/directive/slideBox.js b/js/angular/directive/slideBox.js index f216b690cf..7c0eb4b238 100644 --- a/js/angular/directive/slideBox.js +++ b/js/angular/directive/slideBox.js @@ -133,12 +133,20 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) { '', link: function($scope, $element, $attr, slideBoxCtrl) { - // If the pager should show, append it to the slide box - if ($scope.$eval($scope.showPager) !== false) { - var childScope = $scope.$new(); - var pager = jqLite(''); - $element.append(pager); - $compile(pager)(childScope); + $attr.$observe('showPager', function(show) { + show = $scope.$eval(show); + getPager().toggleClass('hide', !show); + }); + + var pager; + function getPager() { + if (!pager) { + var childScope = $scope.$new(); + pager = jqLite(''); + $element.append(pager); + pager = $compile(pager)(childScope); + } + return pager; } } }; diff --git a/test/html/slideBox.html b/test/html/slideBox.html index 31740aebba..cfaf2f7e29 100644 --- a/test/html/slideBox.html +++ b/test/html/slideBox.html @@ -41,13 +41,13 @@ } - +
- +

Thank you for choosing the Awesome App!