angular.module('ionic.ui', ['ngTouch']) .directive('content', function() { return { restrict: 'E', replace: true, transclude: true, scope: { hasHeader: '@', hasTabs: '@' }, template: '
' } }) .controller('TabsCtrl', function($scope) { var _this = this; angular.extend(this, TabBarController.prototype); TabBarController.call(this, { tabBar: { tryTabSelect: function() {}, setSelectedItem: function(index) { console.log('TAB BAR SET SELECTED INDEX', index); }, addItem: function(item) { console.log('TAB BAR ADD ITEM', item); } } }); $scope.controllers = this.controllers; $scope.$watch('controllers', function(newV, oldV) { console.log("CControlelrs changed", newV, oldV); //$scope.$apply(); }); }) .directive('tabController', function() { return { restrict: 'E', replace: true, scope: {}, transclude: true, controller: 'TabsCtrl', //templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html', template: '
', compile: function(element, attr, transclude, tabsCtrl) { return function($scope, $element, $attr) { }; } } }) // Generic controller directive .directive('tabContent', function() { return { restrict: 'CA', replace: true, transclude: true, template: '
', require: '^tabController', scope: true, link: function(scope, element, attrs, tabsCtrl) { scope.title = attrs.title; scope.icon = attrs.icon; tabsCtrl.addController(scope); } } }) .directive('tabBar', function() { return { restrict: 'E', require: '^tabController', transclude: true, replace: true, scope: true, template: '
' + '' + '
' } }) .directive('tabItem', function() { return { restrict: 'E', replace: true, require: '^tabController', scope: { title: '@', icon: '@', active: '=', tabSelected: '@', index: '=' }, link: function(scope, element, attrs, tabsCtrl) { console.log('Linked item', scope); scope.selectTab = function(index) { tabsCtrl.selectController(scope.index); }; }, template: '' + ' {{title}}' + '' } });