mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(ionTab): make it so tabNav works with ngRepeat
This commit is contained in:
10
js/angular/directive/tab.js
vendored
10
js/angular/directive/tab.js
vendored
@@ -56,12 +56,10 @@ 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) +
|
||||
@@ -69,8 +67,7 @@ function($rootScope, $animate, $ionicBind, $compile) {
|
||||
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
|
||||
@@ -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));
|
||||
|
||||
2
js/angular/directive/tabNav.js
vendored
2
js/angular/directive/tabNav.js
vendored
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user