onsen ui - How to control page routes in the controller? -


onsenui great. fast , easy. however, there not documentation controlling onsen logic in controller.

like instance, want $location.path('/newpath') inside controller. how done in onsen? tried "ons.navigator.pushpage('partials/latestjob.html');" in controller function doesn't work. limited ng-click in onsen go page?

thanks.

in onsen ui 1.04, can access navigator inside controller follows.

$rootscope.ons.navigator.pushpage('new_page.html'); 

another way

$rootscope.ons.$get('#navigator').pushpage(pagename); 

where #navigator id of navigator put on s.t.

<ons-navigator id="navigator" page="page1.html"></ons-navigator>  

this method can choose navigator use.

the third way 1 obtaining navigator scope. example,

var element = document.queryselector( ".navigator-container"); var scope = angular.element( element ).scope(); scope.pushpage(pagename); 

the class name .navigator-container built-in class name of onsen ui navigator. goes in onsen ui 1.0.

adding: example of $rootscope

myapp.controller('myctrl', function($scope, $rootscope) {   $scope.pushpage = function(pagename) {     $rootscope.ons.navigator.pushpage(pagename);   } }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -