Swipe between tabs, onsen-ui

I am using onsen-ui (v1.14) and I am trying to navigate between tabs, for example on facebook messenger, but I can not get it to work.

I tried using the setActiveTab function with ons-gesture-detector in several combinations, but no one worked.

+4
source share
1 answer

Here is what I did (for the toolbar)

CSS

.activebtn .ng-scope{
color: blue;
}

HTML

<ons-template id="list.html">
    <ons-toolbar var="tb">
      <div class="center">
        <ons-toolbar-button class="tbbtn" id="btn_0" ng-click="abc.setActiveCarouselItemIndex(0)">ALL</ons-toolbar-button>
        <ons-toolbar-button class="tbbtn" id="btn_1" ng-click="abc.setActiveCarouselItemIndex(1)">PEOPLE</ons-toolbar-button>
        <ons-toolbar-button class="tbbtn" id="btn_2" ng-click="abc.setActiveCarouselItemIndex(2)"> TOPICS</ons-toolbar-button>
        <ons-toolbar-button class="tbbtn" id="btn_3" ng-click="abc.setActiveCarouselItemIndex(3)">ACCOUNTS</ons-toolbar-button>
        </div>
    </ons-toolbar>


    <ons-carousel style="width: 100%; height: 100%" auto-scroll var="abc" ng-controller="ListCtrl">
        <ons-carousel-item>
         a...
        </ons-carousel-item>
        <ons-carousel-item>
         b...
        </ons-carousel-item>
        <ons-carousel-item>
         c...
        </ons-carousel-item>
        <ons-carousel-item>
         d...
        </ons-carousel-item>
      </ons-carousel>
</ons-template>

Js

    app.controller('ListCtrl', function($scope, $http) {

        $('#btn_0').addClass('activebtn');
        setTimeout(function(){
            abc.on('postchange', function(){
                $('.tbbtn ').removeClass('activebtn');
                $('#btn_' + abc.getActiveCarouselItemIndex()).addClass('activebtn');
            });
        }, 400);
    });
+1
source

All Articles