Skip to content

Commit

Permalink
feat(ionSlideBox): hide/show pager depending on dynamic show-pager at…
Browse files Browse the repository at this point in the history
…tribute
  • Loading branch information
ajoslin committed Feb 9, 2015
1 parent 1e0174a commit c631a8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions js/angular/directive/slideBox.js
Expand Up @@ -133,12 +133,20 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
'</div>',

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('<ion-pager></ion-pager>');
$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('<ion-pager></ion-pager>');
$element.append(pager);
pager = $compile(pager)(childScope);
}
return pager;
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions test/html/slideBox.html
Expand Up @@ -41,13 +41,13 @@
}
</style>
</head>
<body>
<body ng-init="$root.showPager = true">

<div ng-controller="SlideCtrl">
<ion-side-menus>
<ion-side-menu-content>
<ion-header-bar left-buttons="leftButtons" right-buttons="rightButtons" title=""></ion-header-bar>
<ion-slide-box on-slide-changed="slideChanged(index)" show-pager="true" pager-click="pagerClick(index)" does-continue="true" auto-play="false">
<ion-slide-box on-slide-changed="slideChanged(index)" show-pager="{{$root.showPager}}" pager-click="pagerClick(index)" does-continue="true" auto-play="false">
<ion-slide ng-controller="FirstSlideCtrl">
<h3>Thank you for choosing the Awesome App!</h3>
<div id="logo">
Expand Down

0 comments on commit c631a8e

Please sign in to comment.