Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You can not supply no "ons-page" element to "ons-navigator"

Tags:

onsen-ui

On Android device I get this error while loading a onsenui page. this is related to http://onsenui.io javascript library.

You can not supply no "ons-page" element to "ons-navigator".

like image 809
enRaiser Avatar asked Aug 29 '14 05:08

enRaiser


2 Answers

As Vu Nguyen's answer is somewhat correct but it doesn't really explain the other scenarios where this might happen, I'll share my solution on this. For me the problem occurred when I upgraded to Onsen UI 1.3.0 from 1.1.4 and the point where I got this error was on navigator.pushPage('page1.html') where page1.html looked like this:

<ons-template id="page1.html">
  <ons-sliding-menu
        menu-page="menu.html"
        main-page="browse.html"
        side="left">
  </ons-sliding-menu>
</ons-template>

Now the Onsen UI fails to find ons-page which it didn't previously need for some reason. So the solution is to wrap the ons-sliding-menu within ons-page like this

<ons-template id="page1.html">
  <ons-page>
    <ons-sliding-menu
        menu-page="menu.html"
        main-page="browse.html"
        side="left">
    </ons-sliding-menu>
  </ons-page>
</ons-template>
like image 67
Roope Hakulinen Avatar answered Nov 13 '22 09:11

Roope Hakulinen


If there was no ons-page, ons-navigator has nothing to navigate to :)

if you're not using inlined ons-page then make sure it loads a page:

<body ng-app ng-controller="MyCtrl">
    <ons-navigator var="myNavigator" page="mainPage.html">
    </ons-navigator>
</body>
</html>
like image 23
Vu Nguyen Avatar answered Nov 13 '22 09:11

Vu Nguyen