mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Fixed #40 with test
This commit is contained in:
@ -36,6 +36,28 @@ describe('Tab Bar Controller', function() {
|
||||
|
||||
expect(ctrl.getSelectedControllerIndex()).toEqual(1);
|
||||
});
|
||||
|
||||
it('Calls change callback', function() {
|
||||
scope.onControllerChanged = function(oldC, oldI, newC, newI) {
|
||||
};
|
||||
|
||||
// Add a controller
|
||||
ctrl.add({
|
||||
title: 'Cats',
|
||||
icon: 'icon-kitty-kat'
|
||||
});
|
||||
ctrl.add({
|
||||
title: 'Dogs',
|
||||
icon: 'icon-rufus'
|
||||
});
|
||||
|
||||
spyOn(ctrl, 'controllerChanged');
|
||||
|
||||
expect(ctrl.getSelectedControllerIndex()).toEqual(0);
|
||||
ctrl.select(1);
|
||||
|
||||
expect(ctrl.controllerChanged).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tab Bar directive', function() {
|
||||
|
||||
@ -47,8 +47,8 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<tabs animation="fade-in-out">
|
||||
<body ng-controller="RootCtrl">
|
||||
<tabs animation="fade-in-out" controller-changed="onControllerChanged(oldController, oldIndex, newController, newIndex)">
|
||||
|
||||
<tab title="Home" icon-on="icon-ios7-filing" icon-off="icon-ios7-filing-outline" ng-controller="HomeCtrl">
|
||||
<header class="bar bar-header bar-secondary">
|
||||
@ -111,6 +111,14 @@
|
||||
<script>
|
||||
angular.module('tabsTest', ['ionic.ui', 'ionic.service.modal', 'ionic.service.actionSheet'])
|
||||
|
||||
.controller('RootCtrl', function($scope) {
|
||||
$scope.onControllerChanged = function(oldController, oldIndex, newController, newIndex) {
|
||||
console.log('Controller changed', oldController, oldIndex, newController, newIndex);
|
||||
console.log(arguments);
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
.controller('HomeCtrl', function($scope, Modal, ActionSheet) {
|
||||
$scope.items = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user