[Ionic Open source Project Tutorial]-3rd The implementation of the left and right sliding menus (using tabs and Slidebox)

Source: Internet
Author: User

Use tabs and Slidebox to implement left and right sliding menus

1. Place the tab1.htmlChange to the following code:
<ion-view view-title= "Health" >  <ion-content class= "Has-header" >    <ion-slide-box Show-pager= "false" class= "Has-header" on-slide-changed= "slidechanged ($index)" >      <ion-slide ng-repeat= "Slide in Slides" >        <div class= "list" >          < A ng-repeat= "Item in Tabs" class= "Item Item-thumbnail-left" href= "#" >           &NBSP;&LT;IMG Ng-src= "Img/tongeblog.jpg" width= "height=" > "           

Tab1service

for 2.service layers

  angular.module (' starter.services ', [])    .service (' Tab1service ', function ($http) {       this.getclassify = function () {         return [      &NBSP ;    {Name: ' Health information ', viewable:true, Url:domain + '/info/list ', Page:1, rows:20},             {Name: ' Health knowledge ', Viewable:false, Url:domain + '/lore/list ', Page:1, rows:20},             {name: ' Health quiz ', Viewable:false, Url:domain + '/ask/list ', Page:1, rows:20},             {Name: ' Healthy Books ', Viewable:false, Url:domain + '/book/list ', Page:1, rows:20}           ]        }        this.getlist = function (URL, page, rows) {         return $http. Post (URL, {page:page, rows:rows})        }  });  

3. Perfect the corresponding Tab1ctrl

.controller(‘Tab1Ctrl‘, function ($scope, Tab1Service,  $ionicSlideBoxDelegate, $ionicTabsDelegate) {    var items = Tab1Service.getClassify()    $scope.slides = items;    $scope.tabs = items;    var slideIndex = 0;    $scope.slideChanged = function (index) {        $ionicTabsDelegate._instances[1].select(index);    };    $scope.$on(‘$ionicView.afterEnter‘, function () {        $ionicTabsDelegate._instances[1].select($ionicSlideBoxDelegate.currentIndex());    });    $scope.selectedTab = function (index) {        //滑动的索引和速度        $ionicSlideBoxDelegate.slide(index)    }})

4. Code Interpretation

The menu section above uses the tab build, the middle part of the list uses Slidebox, there is no nesting, just to do some processing at the time of their choice.

    • Tab1service: Use dependency injection to invoke the service layer to fetch data.

    • Slidechange:slidebox Select the tab corresponding to the index selected.

    • Selectedtab: When tab is selected, the corresponding Slidebox is selected.

    • Ionicview.afterenter: The first item of tab is selected by default when page loading is complete.

    • _INSTANCES[1]: Because two tab is used in the project

[Ionic Open source Project Tutorial]-3rd The implementation of the left and right sliding menus (using tabs and Slidebox)

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.