mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Angular controller inheriting from our vanilla ctrl
This commit is contained in:
@ -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>'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user