About Navigator Pushpage in OnsenUI

Asked 5 months ago, Updated 5 months ago, 11 views

Thank you for your continuous support.
When I set OnsenUI to the latest v1.2.2, pushPage with the following code no longer works.

TypeError: Cannot read property 'pushPage' of undefined

The error appears (it worked in v1.2.1 by the way).

The $scope.app.navi.pushPage("page.html");

It works, but I don't want to specify the name of the navigator like "app.navi" because I want to use the same child page for multiple navigators.
Please tell me how to deal with it.I look forward to your kind cooperation.

index.html (late head)

<script src="js/app.js"></script>  

<ons-navigator animation="slide" var="app.navi">
      <ons-button modifier="light" ng-click="openpage();"> Push</ons-button>

<ons-template id="page.html">
      <ons-button modifier="light" ng-click="app.navi.popPage('page.html');">Pop</ons-button>


var module=angular.module('app', ['onsen']);
module.controller('AppController', function($scope){ 


2022-09-30 11:35

1 Answers

Recent versions of Onsen UI no longer support the description ons.navigator.Therefore, I think you can solve this problem by explicitly specifying the var attribute of <ons-navigator> and calling the pushPage() method.

HTML side:

<ons-navigator var="myNavigator">

JavaScript side:


It is not a problem to use the same child page in multiple navigators.
Conversely, multiple navigators can define the same name.

2022-09-30 11:35

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.