Monaca Onsen UI Discord Chat Github Repo

Programmatically replace an ons-tab page with another page



  • I have an Angular js app with 3 tabs. I need to open a page that is not part of the ons-tabbar and have the tab bar still be visible. If I use navigator.pushPage or navigator.resetToPage the tab bar is covered by the page. Is there a way to avoid that? I was thinking of perhaps programmatically replacing the tab page - any pointers how to do that? or is there a better way?
    Thanks in advance.
    Andy



  • @heel_curve5
    Answering my own question…
    The ons-tabbar has a method loadPage that replaces the page of the active tab with the one you specify… Unfortunately this is not documented at least in the Angular JS so it took some trial and error.


  • administrators

    @heel_curve5

    Where are you seeing the loadPage method? As far as I can see, ons-tabbar doesn’t have a loadPage method. The only loadPage I can find is ons-navigator.pageLoader.loadPage which wouldn’t solve your problem of the tabbar disappearing.



  • My tab bar is defined as follows

    <ons-tabbar class="bg-grey" var="myTabBar"> 
    

    I put a breakpoint in the code and examined the myTabBar variable
    The loadPage method is in the class that tab bar inherits from.
    In chrome://inspect hover over the tabbar variable and click on “proto” to see all parent methods.


  • administrators

    Thanks for that information