[Solved]Side menu template: $urlRouterProvider.otherwise() called before $state.go()


#1

HI guys,

I am playing around with the side menu example and I noticed the $urlRouterProvider.otherwise('/app/playlists'); gets called before a call to $state.go("my-custom-state"); resulting in a bit of flickering as the playlist view is shown for a split of a second, then the my-custom-state view is shown correctly.

Any suggestion? I am using the sample side menu app ($ ionic start myApp sidemenu), I just added another view I want to activate with $state.go();


#2

yeah but there must be something wrong because “otherwise” is only called if you try to open an invalid/no url.


#3

I am using ng-click=“go()” on a <a> with ng-href="#", is it that? It is probably looking for # as url and triggering $urlRouterProvider.otherwise()

edit: I tested it and yeah, if you bind a function to a <a> tag, urlRouterProvider gets called always


#4

i think the ng-href is the problem… i have some a-tags with ng-click and the otherwise url is never called.

because both hangs on a “click” event and so both is triggered your ng-click-function and the ng-href :slight_smile:


#5

yep, that is true.

I was using ng-href because I am building the url dynamically. I will switch to <button> passing the parameters using ng-click