I’m not sure if it has to do with the way I have it set up to use my server or if it is actually an ionic and ui-router problem. This works with my web version.
Are you running this in your emulator or real device?
Because if you’re not working on your computer localhost:5000 will not work. You can’t use this address outside of your working machine. You will need to use your IP instead.
Now that this post is showing, I’ll post my update. As for that, I’m running it in the browser with ionic serve --lab. I haven’t set up my IP for it to work off my phone, but then I’ll just use the pushed up site.
Also, to be clear, the login does work.
As for my update. It works if I have two $state.go's:
The role check and authorize really don’t make a difference. You could take them out and it would still behave the same. The role check just decodes JWT token.
So right now it “works”, but if you have a trainer account you have to hit login twice. I would love to just not have to have two $state.go
What does your ./user/views/content.html file look like?
I would put a breakpoint at the start of the UserExercises controller and see if the controller gets initialized. If it does not get that far then there is a problem in the router initialization of the state.
I would also check the status code and make sure it is 200, there are other codes that will cause success to be called but not 200.
I would also take out the http call entirely and just call $state.go(‘user.exercises’) in the login function and see if that works.
Failing that I would create a new project, add the user route and the user exercises route and the login route and get that working - make what you have as simple as possible then post it to codepen or possibly email it me and I can have a look.
I do this stuff all the time and it should be trivial to fix. All the time I have had the $stateChangeError be the most useful for tracking down these types of errors.
The UserExercise controller gets initiated because I can see that it logs some data from a function inside of it.
I will check on the status code, but I doubt it’s anything else because it’s no different that what I use on the web version.
If I take out the $http.post it works as intended.
I probably will have to make a new project and try that. Unfortunately, I don’t get a $stateChangeError, it actually is a $stateChangeSuccess.
If I take out the title from the <ion-view> on the login page, you can see that after I click login, the title switches to “Exercises” but the view inside the <ion-view> doesn’t change.
And it looks like I found the source of the problem. It has to do with the ng-if="platform.isAndroid/IOS" which is causing the views not to change entirely.