0

What is a proper way (best code organization) to get user object from JWT in storage on full page refresh (it requires new ajax request) ?

How can I perform an ajax request before my angular app's routing start? Adding an extra request in resolve part on every route is bad (DRY). How I can simplify that?

Is an abstract view (using UI router) with resolve best solution?

Vlatko
  • 1,385
  • 1
  • 18
  • 35
  • This question seems to be opinion based on the fact that you are asking for the "best" way of doing something. That in mind, if you provided a few specific code examples it is possible that someone may have a suggestion based on those. Traditionally in angular you wouldn't load data before the SPA starts but instead via model binding in the controller. You might also look at using [$resource](https://docs.angularjs.org/api/ngResource/service/$resource) in angular. – drew_w Jan 01 '15 at 23:29
  • you have a few options for loading data before starting the angular app. See: [Initialize Angularjs Service with Asynchronous Data](http://stackoverflow.com/questions/16286605/initialize-angularjs-service-with-asynchronous-data) – user2943490 Jan 01 '15 at 23:31

1 Answers1

0

It is a good practice to use ajax with jwt for user experience. you can set your user object to $rootscope once then use in any route.

using resolve with ui-router is perfect way for your situation as i think .