mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
/**
|
|
* @ngdoc service
|
|
* @name $ionicTabsDelegate
|
|
* @module ionic
|
|
*
|
|
* @description
|
|
* Delegate for controlling the {@link ionic.directive:ionTabs} directive.
|
|
*
|
|
* Methods called directly on the $ionicTabsDelegate service will control all ionTabs
|
|
* directives. Use the {@link ionic.service:$ionicTabsDelegate#$getByHandle $getByHandle}
|
|
* method to control specific ionTabs instances.
|
|
*
|
|
* @usage
|
|
*
|
|
* ```html
|
|
* <body ng-controller="MyCtrl">
|
|
* <ion-tabs>
|
|
*
|
|
* <ion-tab title="Tab 1">
|
|
* Hello tab 1!
|
|
* <button ng-click="selectTabWithIndex(1)">Select tab 2!</button>
|
|
* </ion-tab>
|
|
* <ion-tab title="Tab 2">Hello tab 2!</ion-tab>
|
|
*
|
|
* </ion-tabs>
|
|
* </body>
|
|
* ```
|
|
* ```js
|
|
* function MyCtrl($scope, $ionicTabsDelegate) {
|
|
* $scope.selectTabWithIndex = function(index) {
|
|
* $ionicTabsDelegate.select(index);
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
IonicModule
|
|
.service('$ionicTabsDelegate', delegateService([
|
|
/**
|
|
* @ngdoc method
|
|
* @name $ionicTabsDelegate#select
|
|
* @description Select the tab matching the given index.
|
|
*
|
|
* @param {number} index Index of the tab to select.
|
|
* @param {boolean=} shouldChangeHistory Whether this selection should load this tab's
|
|
* view history (if it exists) and use it, or just load the default page.
|
|
* Default false.
|
|
* Hint: you probably want this to be true if you have an
|
|
* {@link ionic.directive:ionNavView} inside your tab.
|
|
*/
|
|
'select',
|
|
/**
|
|
* @ngdoc method
|
|
* @name $ionicTabsDelegate#selectedIndex
|
|
* @returns `number` The index of the selected tab, or -1.
|
|
*/
|
|
'selectedIndex'
|
|
/**
|
|
* @ngdoc method
|
|
* @name $ionicTabsDelegate#$getByHandle
|
|
* @param {string} handle
|
|
* @returns `delegateInstance` A delegate instance that controls only the
|
|
* {@link ionic.directive:ionTabs} directives with `delegate-handle` matching
|
|
* the given handle.
|
|
*
|
|
* Example: `$ionicTabsDelegate.$getByHandle('my-handle').select(0);`
|
|
*/
|
|
]))
|
|
|