Onsen ui navigation with parameters

后端 未结 2 731
Happy的楠姐
Happy的楠姐 2021-01-14 07:32

I am using onsen ui with typescript and angularJS with an ons-sliding-menu:

  

        
相关标签:
2条回答
  • 2021-01-14 08:18

    You say every page looks like the one you pasted. Do you have several <ons-navigator> tags? You should really only need one.

    If you do

    $scope.navigator.pushPage('somepage.html', {param1: 'bla'});
    

    You should be able to do

    console.log($scope.navigator.getCurrentPage().options.param1);
    

    See pen:

    http://codepen.io/argelius/pen/OPJRPe

    Do you have the navigator attached to some scope that is parent of the scope of the controller for the page you push?

    In your parent controller you could do:

    ons.ready(function() {
      $scope.navigator = $window.myNavigator
    });
    

    And then use that object in the child controllers.

    0 讨论(0)
  • 2021-01-14 08:25

    I facing same problem, my solution for this is basicaly combine both in something like this

    <ons-sliding-menu
            menu-page="menu.html"
            side="left"
            max-slide-distance="250px" 
            var="menu">
            <div class="main">
                <ons-navigator title="Navigator" var="myNavigator" page="home.html"></ons-navigator>
            </div>          
        </ons-sliding-menu>
    

    In this way you can use both SlideMenu and Navigator pattern

    0 讨论(0)
提交回复
热议问题