Skip to content

Commit

Permalink
fix(ionTab): make it so tabNav works with ngRepeat
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Apr 30, 2014
1 parent 5cdc76a commit 288d4ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
10 changes: 4 additions & 6 deletions js/angular/directive/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,18 @@ function($rootScope, $animate, $ionicBind, $compile) {
element[0].querySelector('data-ion-nav-view');
var navViewName = navView && navView.getAttribute('name');


//We create the tabNavElement in the compile phase so that the
//We create the tabNavTemplate in the compile phase so that the
//attributes we pass down won't be interpolated yet - we want
//to pass down the 'raw' versions of the attributes
var tabNavElement = angular.element(
'<ion-tab-nav' +
var tabNavTemplate = '<ion-tab-nav' +
attrStr('ng-click', attr.ngClick) +
attrStr('title', attr.title) +
attrStr('icon', attr.icon) +
attrStr('icon-on', attr.iconOn) +
attrStr('icon-off', attr.iconOff) +
attrStr('badge', attr.badge) +
attrStr('badge-style', attr.badgeStyle) +
'></ion-tab-nav>'
);
'></ion-tab-nav>';

//Remove the contents of the element so we can compile them later, if tab is selected
//We don't use regular transclusion because it breaks element inheritance
Expand Down Expand Up @@ -113,6 +110,7 @@ function($rootScope, $animate, $ionicBind, $compile) {
}
}

var tabNavElement = angular.element(tabNavTemplate);
tabNavElement.data('$ionTabsController', tabsCtrl);
tabNavElement.data('$ionTabController', tabCtrl);
tabsCtrl.$tabsElement.append($compile(tabNavElement)($scope));
Expand Down
2 changes: 1 addition & 1 deletion js/angular/directive/tabNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IonicModule
tabCtrl = ctrls[1];

//Remove title attribute so browser-tooltip does not apear
$element[0].removeAttribute('title');
// $element[0].removeAttribute('title');

$scope.selectTab = function(e) {
e.preventDefault();
Expand Down
31 changes: 16 additions & 15 deletions test/html/tabs-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@
<script src="../../../../dist/js/ionic.bundle.js"></script>
</head>
<body ng-init="pages=[
{'id':'first',
'icon':'ion-link'
},
{'id':'first',
'icon':'ion-link'
},
{'id':'second',
'icon':'icon ion-link'
{'id':'second',
'icon':'icon ion-link'
},
},
{'id':'third',
'icon':'ion-link'
{'id':'third',
'icon':'ion-link'
}
}
]">
<ion-tabs tabs-style="tabs-top tabs-positive tabs-icon-top">
<ion-tab ng-repeat="p in pages" title="{{p.id}}" icon="{{p.icon}}">
<header class="bar bar-positive bar-header"></header>
<ion-content class="has-header has-subheader">
<p></p>
]">
<ion-tabs class="tabs-top tabs-positive tabs-icon-top">
<ion-tab ng-repeat="p in pages" title="{{p.id}}" icon="{{p.icon}}">
<ion-header-bar class="bar-positive">
<h1 class="title">Hello</h1>
</ion-header-bar>
<ion-content>
<b>{{p.id}}</b>
<p>...</p>
<p>...</p>
Expand Down

0 comments on commit 288d4ac

Please sign in to comment.