From ed5cb0ca5fd42504a70a4fc0c6c3beb1446052bf Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 19 Sep 2013 15:58:03 -0500 Subject: [PATCH] Fixed tabs angular demo and made it better --- hacking/TabAngular.js | 28 ++++++++++++---------------- hacking/navAngular.html | 32 ++++++++++++++++++++++++++++++-- hacking/tabsAngular.html | 16 ++++++++-------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/hacking/TabAngular.js b/hacking/TabAngular.js index 3b4ce48629..e0a7765401 100644 --- a/hacking/TabAngular.js +++ b/hacking/TabAngular.js @@ -34,11 +34,11 @@ angular.module('ionic.ui', ['ngTouch']) $scope.$watch('controllers', function(newV, oldV) { console.log("CControlelrs changed", newV, oldV); - $scope.$apply(); + //$scope.$apply(); }); }) -.directive('tabs', function() { +.directive('tabController', function() { return { restrict: 'E', replace: true, @@ -55,17 +55,17 @@ angular.module('ionic.ui', ['ngTouch']) }) // Generic controller directive -.directive('tabController', function() { +.directive('tabContent', function() { return { - restrict: 'E', + restrict: 'CA', replace: true, transclude: true, template: '
', - require: '^tabs', - scope: { - title: '@' - }, + require: '^tabController', + scope: true, link: function(scope, element, attrs, tabsCtrl) { + scope.title = attrs.title; + scope.icon = attrs.icon; tabsCtrl.addController(scope); } } @@ -75,9 +75,10 @@ angular.module('ionic.ui', ['ngTouch']) .directive('tabBar', function() { return { restrict: 'E', - require: '^tabs', + require: '^tabController', transclude: true, replace: true, + scope: true, template: '
' + '' + '
' @@ -88,7 +89,7 @@ angular.module('ionic.ui', ['ngTouch']) return { restrict: 'E', replace: true, - require: '^tabs', + require: '^tabController', scope: { title: '@', icon: '@', @@ -97,15 +98,10 @@ angular.module('ionic.ui', ['ngTouch']) index: '=' }, link: function(scope, element, attrs, tabsCtrl) { - // Store the index of this list item, which - // specifies which tab item it is - //scope.tabIndex = element.index(); - + console.log('Linked item', scope); scope.selectTab = function(index) { - console.log('SELECT TAB', scope.index); tabsCtrl.selectController(scope.index); }; - }, template: '' + diff --git a/hacking/navAngular.html b/hacking/navAngular.html index c3f32503ee..a33194b244 100644 --- a/hacking/navAngular.html +++ b/hacking/navAngular.html @@ -9,13 +9,41 @@ + + + - + @@ -30,7 +58,7 @@ pageNumber++; - var el = $compile('
' + + var el = $compile('')(childScope, cb); diff --git a/hacking/tabsAngular.html b/hacking/tabsAngular.html index c79ade0ed6..0480ff7516 100644 --- a/hacking/tabsAngular.html +++ b/hacking/tabsAngular.html @@ -16,8 +16,8 @@ - - + +

Tab Bars

@@ -29,26 +29,26 @@ - +
- +

About

About Us

- +
- +

Settings

Settings

- - +
+