Skip to content

Commit 288d4ac

Browse files
committed
fix(ionTab): make it so tabNav works with ngRepeat
1 parent 5cdc76a commit 288d4ac

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

js/angular/directive/tab.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,18 @@ function($rootScope, $animate, $ionicBind, $compile) {
5656
element[0].querySelector('data-ion-nav-view');
5757
var navViewName = navView && navView.getAttribute('name');
5858

59-
60-
//We create the tabNavElement in the compile phase so that the
59+
//We create the tabNavTemplate in the compile phase so that the
6160
//attributes we pass down won't be interpolated yet - we want
6261
//to pass down the 'raw' versions of the attributes
63-
var tabNavElement = angular.element(
64-
'<ion-tab-nav' +
62+
var tabNavTemplate = '<ion-tab-nav' +
6563
attrStr('ng-click', attr.ngClick) +
6664
attrStr('title', attr.title) +
6765
attrStr('icon', attr.icon) +
6866
attrStr('icon-on', attr.iconOn) +
6967
attrStr('icon-off', attr.iconOff) +
7068
attrStr('badge', attr.badge) +
7169
attrStr('badge-style', attr.badgeStyle) +
72-
'></ion-tab-nav>'
73-
);
70+
'></ion-tab-nav>';
7471

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

113+
var tabNavElement = angular.element(tabNavTemplate);
116114
tabNavElement.data('$ionTabsController', tabsCtrl);
117115
tabNavElement.data('$ionTabController', tabCtrl);
118116
tabsCtrl.$tabsElement.append($compile(tabNavElement)($scope));

js/angular/directive/tabNav.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ IonicModule
2626
tabCtrl = ctrls[1];
2727

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

3131
$scope.selectTab = function(e) {
3232
e.preventDefault();

test/html/tabs-repeat.html

+16-15
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@
88
<script src="../../../../dist/js/ionic.bundle.js"></script>
99
</head>
1010
<body ng-init="pages=[
11-
{'id':'first',
12-
'icon':'ion-link'
13-
},
11+
{'id':'first',
12+
'icon':'ion-link'
13+
},
1414
15-
{'id':'second',
16-
'icon':'icon ion-link'
15+
{'id':'second',
16+
'icon':'icon ion-link'
1717
18-
},
18+
},
1919
20-
{'id':'third',
21-
'icon':'ion-link'
20+
{'id':'third',
21+
'icon':'ion-link'
2222
23-
}
23+
}
2424
25-
]">
26-
<ion-tabs tabs-style="tabs-top tabs-positive tabs-icon-top">
27-
<ion-tab ng-repeat="p in pages" title="{{p.id}}" icon="{{p.icon}}">
28-
<header class="bar bar-positive bar-header"></header>
29-
<ion-content class="has-header has-subheader">
30-
<p></p>
25+
]">
26+
<ion-tabs class="tabs-top tabs-positive tabs-icon-top">
27+
<ion-tab ng-repeat="p in pages" title="{{p.id}}" icon="{{p.icon}}">
28+
<ion-header-bar class="bar-positive">
29+
<h1 class="title">Hello</h1>
30+
</ion-header-bar>
31+
<ion-content>
3132
<b>{{p.id}}</b>
3233
<p>...</p>
3334
<p>...</p>

0 commit comments

Comments
 (0)