Hey there,
I’ve an issue w/ $state.go() to change views.
I’ve implemented a login-system which broadcasts an “AuthEvent” once the user is logged in (or if there’s a login-token available).
Unfortunately, my $state.go()-directives don’t do anything expect for changing the URL (i.e. index.html#/ --> index.html#/login) - but not the view on the screen! If I reload the page after the URL-change, everything is displayed correctly.
When you catch the event, try wrapping the $state.go('login') in a $timeout. Also, if you are already on the login state/url then you will have to explicitly refresh. Do you have multiple directives trying to change the ui-state at once?
This now takes 2s to change the URL (as expected), but the view doesn’t load anyways (at least until I refresh the page of course).
I’ve also added a debug-log in front of every $state.go()-directive to find out if there are multiple calls occurring at once, but apparently, there’s only the one now wrapped inside the timeout.
Second question, hope it’s okay to put this in this thread as well: Is there any method to automatically fire a function ($http-event in my case) when a specific view is rendered? e.g., after the login, fetch data from the server and populate the page.
The purpose of the $timeout is to add your ‘action’ to the end of the digest cycle. It’s an AngularJS thing. You don’t need to add a delay though, you would want to do something like this probably:
I have tried to change my templates to match yours, but it hasn’t changed anything. I have changed around a default tab project, on one of the tabs I would like to go to an entirely different state outside of the tabs.
Experiencing lazy-loading/Cache issue in "version": "1.0.0-beta.14",
Where the controller is not being instantiated, when an state is being invoked from another controller like:
$state.go('tab.home');
$state.go() worked fine & controller instantiated successfully in this "version": "1.0.0-beta.8",
$state is being injected into controller fine.
tried below combinations (Sometimes with event.preventDefault();), but to no avail.
The issue I was facing above is due to the cached views introduced in “version”: “1.0.0-beta.14”,. At this time, I was able to resolve it by disabling cache for all views through config provider.
$ionicConfigProvider.views.maxCache(0);
It would be neat to have this option available/controllable for a view than for the entire app, something like:
Does anyone think this is promotable to a bug? The fact that disabling the cache fixes this “simply navigation” workflow makes me think what are the real usages of cache system and what are the risks of it.
Using an empty $timeout fixed an issue I was having (on iOS), where the $state.go(state) call would sometimes ‘go’ to the very same view. Will keep DOM rendering behaviour in mind in future - thanks!