Fixed #40 with test

This commit is contained in:
Max Lynch
2013-10-29 14:27:54 -05:00
parent 01bbf5c1fa
commit 082259dcfb
7 changed files with 65 additions and 8 deletions

View File

@ -858,6 +858,14 @@ angular.module('ionic.ui.tabs', ['ngAnimate'])
angular.extend(this, ionic.controllers.TabBarController.prototype);
ionic.controllers.TabBarController.call(this, {
controllerChanged: function(oldC, oldI, newC, newI) {
$scope.controllerChanged && $scope.controllerChanged({
oldController: oldC,
oldIndex: oldI,
newController: newC,
newIndex: newI
});
},
tabBar: {
tryTabSelect: function() {},
setSelectedItem: function(index) {},
@ -891,7 +899,8 @@ angular.module('ionic.ui.tabs', ['ngAnimate'])
restrict: 'E',
replace: true,
scope: {
animation: '@'
animation: '@',
controllerChanged: '&'
},
transclude: true,
controller: 'TabsCtrl',

6
dist/js/ionic.js vendored
View File

@ -4923,7 +4923,6 @@ ionic.controllers.TabBarController = ionic.controllers.ViewController.inherit({
if(shouldChange) {
this.setSelectedController(index);
this.controllerChanged && this.controllerChanged(this.selectedController, this.selectedIndex);
}
},
@ -4932,11 +4931,16 @@ ionic.controllers.TabBarController = ionic.controllers.ViewController.inherit({
if(index >= this.controllers.length) {
return;
}
var lastController = this.selectedController;
var lastIndex = this.selectedIndex;
this.selectedController = this.controllers[index];
this.selectedIndex = index;
this._showController(index);
this.tabBar.setSelectedItem(index);
this.controllerChanged && this.controllerChanged(lastController, lastIndex, this.selectedController, this.selectedIndex);
},
_showController: function(index) {