Defining different abstract layout for different tabs in ionic -
can have 2 states abstract:true i.e base layout different tabs?
forexample, tab-1, tab-2 , tab-3, need have tabs.html
abstract:true in state provider , tab-4, need have menu.html abstract:true in state provder subsequent states inherit it.
something this:
.config(function($stateprovider, $urlrouterprovider) { // ionic uses angularui router uses concept of states // learn more here: https://github.com/angular-ui/ui-router // set various states app can in. // each state's controller can found in controllers.js $stateprovider // setup abstract state tabs directive .state('tab', { url: '/tab', abstract: true, templateurl: 'templates/tabs.html' }) // each tab has own nav history stack: .state('tab.dash', { url: '/dash', views: { 'tab-dash': { templateurl: 'templates/tab-dash.html', controller: 'dashctrl' } } }) .state('tab.chats', { url: '/chats', views: { 'tab-chats': { templateurl: 'templates/tab-chats.html', controller: 'chatsctrl' } } }) .state('tab.chat-detail', { url: '/chats/:chatid', views: { 'tab-chats': { templateurl: 'templates/chat-detail.html', controller: 'chatdetailctrl' } } }) .state('tab.account', { url: '/account', views: { 'tab-account': { templateurl: 'templates/tab-account.html', controller: 'accountctrl' } } }) $stateprovider .state('app', { abstract: true, templateurl: "templates/menu.html" }) .state('app.events', { url: "/events", views: { 'menucontent': { templateurl: "templates/events.html", controller: 'eventsctrl' } } })
tabs.html looks this:
<!-- create tabs icon , label, using tabs-positive style. each tab's child <ion-nav-view> directive have own navigation history transitions views in , out. --> <ion-tabs class="tabs-icon-top tabs-color-active-positive"> <!-- dashboard tab --> <ion-tab title="status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash"> <ion-nav-view name="tab-dash"></ion-nav-view> </ion-tab> <!-- chats tab --> <ion-tab title="chats" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/tab/chats"> <ion-nav-view name="tab-chats"></ion-nav-view> </ion-tab> <!-- account tab --> <ion-tab title="account" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/account"> <ion-nav-view name="tab-account"></ion-nav-view> </ion-tab> <!--practice tab --> <ion-tab title="events" icon-off="ion-ios-arrow-forward " icon-on="ion-ios-arrow-forward-utline" href="#/tab/events"> <ion-nav-view name="menucontent"></ion-nav-view> </ion-tab> </ion-tabs>
menu.html:
<ion-side-menus enable-menu-with-back-views="true"> <ion-side-menu-content> <ion-nav-bar class="bar-stable"> <ion-nav-back-button> </ion-nav-back-button> <ion-nav-buttons side="left"> <button class="button button-icon button-clear ion-navicon" menu-toggle="left"> </button> </ion-nav-buttons> </ion-nav-bar> <ion-nav-view name="menucontent"></ion-nav-view> </ion-side-menu-content> <ion-side-menu side="left"> <ion-header-bar class="bar-stable"> <h1 class="title">my app</h1> </ion-header-bar> <ion-content scroll="false"> <ion-list> <ion-item nav-clear menu-close href="#/events"> events </ion-item> </ion-list> </ion-content> </ion-side-menu> </ion-side-menus>
it not work though.is possible it? if not alternative?
yes, can add multiple abstract states.
here documentation angular states. according docs:
an abstract state can have child states can not activated itself. 'abstract' state state can't transitioned to. activated implicitly when 1 of descendants activated.
Comments
Post a Comment