Angular controller inheriting from our vanilla ctrl

This commit is contained in:
Max Lynch
2013-09-17 19:25:39 -05:00
parent 8c26932c7b
commit a93618d876
2 changed files with 21 additions and 5 deletions

View File

@ -14,6 +14,19 @@ angular.module('ionic.ui', [])
}) })
.controller('TabsCtrl', function($scope) { .controller('TabsCtrl', function($scope) {
var _this = this;
angular.extend(this, TabBarController.prototype);
var tab = document.createElement('div');
tab.className = 'tabs';
TabBarController.call(this, {
tabBar: new TabBar({el: tab})
});
$scope.controllers = this.controllers;
/*
// Controller stuff goes here // Controller stuff goes here
$scope.items = []; $scope.items = [];
@ -23,6 +36,7 @@ angular.module('ionic.ui', [])
title: item.title title: item.title
}); });
}; };
*/
}) })
.directive('tabs', function() { .directive('tabs', function() {
@ -53,7 +67,7 @@ angular.module('ionic.ui', [])
title: '@' title: '@'
}, },
link: function(scope, element, attrs, tabsCtrl) { link: function(scope, element, attrs, tabsCtrl) {
tabsCtrl.addItem(scope); tabsCtrl.addController(scope);
} }
} }
}) })
@ -66,8 +80,8 @@ angular.module('ionic.ui', [])
transclude: true, transclude: true,
replace: true, replace: true,
template: '<div class="tabs">' + template: '<div class="tabs">' +
'<a href="#" class="tab-item" ng-repeat="item in items">' + '<a href="#" class="tab-item" ng-repeat="controller in controllers">' +
'<i class="{{item.icon}}"></i> {{item.title}}' + '<i class="{{item.icon}}"></i> {{controller.title}}' +
'</a>' + '</a>' +
'</div>' '</div>'
} }

View File

@ -60,12 +60,14 @@ TabBarController.prototype = {
for(var i = 0, j = this.controllers.length; i < j; i ++) { for(var i = 0, j = this.controllers.length; i < j; i ++) {
c = this.controllers[i]; c = this.controllers[i];
//c.detach && c.detach(); //c.detach && c.detach();
c.setVisible(false); c.isVisible = false;
c.visibilityChanged && c.visibilityChanged();
} }
c = this.controllers[index]; c = this.controllers[index];
//c.attach && c.attach(); //c.attach && c.attach();
c.setVisible(true); c.isVisible = true;
c.visibilityChanged && c.visibilityChanged();
}, },
_clearSelected: function() { _clearSelected: function() {