ionic Tabs Bar Operations
ion-tabs
ion-tabs is a tab bar consisting of a group of page tabs. Pages can be switched by tapping a tab.
For iOS, it appears at the bottom of the screen; on Android it appears at the top of the screen (below the navigation bar).
Usage
Example
<
ion-tabs
class
=
"tabs-positive tabs-icon-only
"
<
ion-tab
title
=
"
Home
"
icon-on
=
"
ion-ios-filing
"
icon-off
=
"
ion-ios-filing-outline
"
ion-tab
<
ion-tab
title
=
"
About
"
icon-on
=
"
ion-ios-clock
"
icon-off
=
"
ion-ios-clock-outline
"
ion-tab
<
ion-tab
title
=
"
Settings
"
icon-on
=
"
ion-ios-gear
"
icon-off
=
"
ion-ios-gear-outline
"
ion-tab
ion-tabsTry it »
The effect is shown below:
API
| property | Type | Details |
|---|---|---|
| delegate-handle |
(optional)
| `string` |This handle uses$ionicTabsDelegateto identify these tabs.
ion-tab
Belongs to ionTabs
Contains a tab's content. This content exists only in the given tab when it is selected.
Each ionTab has its own browsing history.
Usage
API
| property | Type | Details |
|---|---|---|
| title | 字符串 |
The title of the tab. |
| href |
(optional)
| `string` |The link the tab will navigate to when tapped.
| | iconThe tab's icon. If a value is given, it becomes the default for ion-on and ion-off.
| | icon-onThe icon of the selected tab.
| | icon-offThe icon of the unselected tab.
| | badgeThe badge on the tab (usually a number).
| | badge-styleThe style of the badge on the tab (e.g., tabs-positive).
| | on-selectTriggered when a tab is selected.
| | on-deselectTriggered when a tab is deselected.
| | ng-clickNormally, a tab is selected when tapped. If ng-Click is set, it will not be selected. You can use $ionicTabsDelegate.select() to specify switching tabs.
|$ionicTabsDelegate
Authorization to control the ionTabs directive.
This method directly calls the $ionicTabsDelegate service to control all ionTabs directives. Use the $getByHandle method to control specific ionTabs instances.
Usage
你好,标签1!
你好标签2!
function MyCtrl($scope, $ionicTabsDelegate) {
$scope.selectTabWithIndex = function(index) {
$ionicTabsDelegate.select(index);
}
}
Method
select(index, [shouldChangeHistory])
Select a tab to match the given index.
| Parameters | Type | Details |
|---|---|---|
| index | 数值 |
The index of the tab to select. |
| shouldChangeHistory |
(optional)
| `boolean` |Whether this option should load and use this tab's browsing history (if it exists), or only load the default page. Default is false. Tip: if aion-nav-viewis in a tab, you may need to set it to true.
selectedIndex()
** Returns: ** number, the index of the selected tab, such as -1.
$getByHandle(handle)
| Parameters | Type | Details |
|---|---|---|
| handle | 字符串 |
For example:
$ionicTabsDelegate.$getByHandle('my-handle').select(0);