javascript - want to go to home page when clicked on back button in mobile? -


i developing mobile app on ionic framework. has side menu subcategories. whenever go subcategory more once , click on button in android mobile, retraces whole of states went through don't want.

.state('eventmenu', {   url: "/event",   abstract: true,   templateurl: "templates/event-menu.html" })    .state('eventmenu.home', {   url: "/home",   views: {     'menucontent' :{       templateurl: "templates/home.html",       controller: "homectrl"     }   } })   .state('categorymenu', {   url: "/category",   abstract: true,   templateurl: "templates/event-menu.html" })  .state('categorymenu.compound', {   url: "/compound",   views: {     'menucontent' :{       templateurl: "templates/categories.html",       controller: "categoriesctrl"     }   } })  .state('categorymenu.research', {   url: "/research",   views: {     'menucontent' :{       templateurl: "templates/categories.html",       controller: "categoriesctrl"     }   } })    .state('categorymenu.product', {   url: "/product",   views: {     'menucontent' :{       templateurl: "templates/product.html",       controller: "categoriesctrl"     }   } })   $urlrouterprovider.otherwise("/event/home"); }) 

i want button redirect user home page. here categorymenu.compound , categorymenu.research contents of sidemenu, has got many subcategories redirect categorymenu.product page.

redefine backbutton function on each controller loading, can use :$ionicplatform.registerbackbuttonaction(function(){$state.go('targetview')}, priority, [actionid])

but need clear cache when reload views (for redefine backbutton each time , have several possible return).

you can add param in each redirect :

$state.go('targetview',{cache: false}); 

or add param in state description

.state('eventmenu.home', {   cache: false   url: "/home",   views: {     'menucontent' :{       templateurl: "templates/home.html",       controller: "homectrl"     }   } }) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -