Ionic Component Ion-tabs tab Toggle Effect Instance _javascript Tips

Source: Internet
Author: User

Introduced

Ion-tabs is the tab component in Ionic, and the route uses Angular-ui-router.js. So we must master Uiroute first.

Effect chart


Instance Code

Index.html

<body ng-app= "starter" >
 <!--ion-nav-view used to render templates-->
 <ion-nav-view></ion-nav-view>
</body>

Tab-index.html

<ion-tabs class= "Tabs-icon-only tabs-icon-top" >
 <!--href: tab corresponding status Icon-on:ion-tab not highlighted icon  Icon-off: Ion-tab Highlight icon-->
 <ion-tab title= "Home" href= "#/tabs/home" icon-on= "Ion-new-home-off" icon-off= "Ion-new-home" >
 <!--have multiple ion-nav-view in the same state, so you need to set the Name property for them. and the corresponding state and render view when the routing is configured-->
 <ion-nav-view name= "Tab-home" ></ion-nav-view>
 </ion-tab>
 
 <ion-tab title= "Taobao" href= "#/tabs/taobao" icon-off= "ION-NEW-TF" icon-on= "Ion-new-tf-off" >
 < Ion-nav-view name= "Tab-taobao" ></ion-nav-view>
 </ion-tab>
 
 <ion-tab title= "Good goods" Icon-off = "Ion-new-zhemai" icon-on= "Ion-new-zhemai-off" >
 </ion-tab>
 
 <ion-tab title= "My href=" #/tabs /user "icon-off=" Ion-new-user "icon-on=" Ion-new-user-off "> <ion-nav-view name=" tab-user "></
 ion-nav-view>
 </ion-tab>
</ion-tabs>

Config.js

. State ("tabs", {
 URL: "/tabs",
 templateurl: "templates/tab/tab-index.html",
 Controller: "Tabs"
})

. State ("Tabs.home", {
 URL: "/home", views
 : {
 "tab-home": {
  templateurl: "templates/home/ Home.html '
 }
 }
}
. State ("Tabs.taobao", {
 URL: '/taobao ', views
 : {
 "Tab-taobao ': {
  templateurl: ' Templates/taobao/taobao.html '}}}
 . State
("Tabs.user", {
 URL: " /user ", views
 : {
 " Tab-user ": {
  templateurl:" Templates/user/user.html "}}
)

You can then write the contents of each tab under Home.html taobao.html user.html

For example:

Home.html

<ion-header-bar class= "Bar bar-header assertive-bg bar-home" >
 <ion-title> Home </ion-title>
</ion-header-bar>

<ion-view>
 <ion-content>

 <ion-refresher pulling-text= "pull down Refresh" On-refresh= "Dorefresh ()" ></ion-refresher>

 </ion-content>
</ion-view>

Note: Do not place ion-tabs in a ion-content element; it can cause a certain known CSS error.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.