router in a live page


after 0.29 we can create live pages and not just templates in a navigator / router. My question is: how do i call the router inside the live page js ?

For example:

 <Router ux:Name="myRouter" BackButtonAction="None"/>
   <Page Name="page1">
     <ux:Include File="Page1.ux" />

   <TemplatePage      ux:Template="templatePage"  router="myRouter" />

TemplatePage class would look similar to:

<Panel  ux:Class="TemplatePage">
    <Router ux:Dependency="router" />
    <JavaScript File="templatePage.js" />

so i would be able to call router.push from the templatePage.js

my question is: how do i call the router from the Page1.js (that would be declared in the Page1.ux) ?


This works the same as for when you use ux:Template. Here is an example:

		<Router ux:Name="router" />
		<Navigator DefaultTemplate="page1">
			<Page ux:Name="page1" Color="Yellow">
					function pushPage2() { router.push("page2"); }

					module.exports = { pushPage2 };
				<Button Text="Page2" Clicked="{pushPage2}"/>
			<Page ux:Name="page2" Color="Red">


that’s what i expected but in my app i got a “router is not defined”… but i will check and if i’ll upload a an example if i don’t find the error.


Make sure you do
and not

in that case. Since the name of your router is myRouter

yes i did (actaully i got a "myRouter is not defined)

I saw where is the error but i guess it may be a bug (i did a workaround) as it depends on when i call “myRouter.push” inside the page1.js (in one function it works in the other i get the “myRouter is not defined” (same code))

Can u pls tell me where can i upload an example?

Its quite hard to help since i have no idea whats behind your ux:Include

<ux:Include File="Page1.ux" />

Repro cases can be uploaded here :