In my mind, a global state is a static state that lasts throughput the life of the application.
Why does this matter? Thinking of a real world sample, it is those parameters before the hash that I want to not only be useful within my Angular app, I want that data to potentially have meaning for the server and be the baseline entry point. I could possibly use it as a mechanism to send a value (or more) from server to client without attempting to mash the hash-tag into my server redirects/urls. This same mechanism can be utilized in in the event that a user is being redirected to the server – or refreshes the page manually.
Additionally, changing the hash-tag manually doesn’t necessarily change state. However, if someone manually modifies my base url (global state), the page will be refreshed and the application/server can respond accordingly.
An issue with this approach is that now, I have to grab that value before it’s lost and deal with maintaining it across states.
This looks like a workable solution to me. But Angular, or specifically ui-router, doesn’t let you have access to the query parameters that exist before the hash tag. However, we can remedy this with a dependency resolver and the $location service.
This gets me what I want – a global state. If the user modifies the “widgetId,” they’ll get redirect back to the server and our work flow starts all over. And, if I’m doing something like passing that “widgetId” with my API calls, I have a single point of reference that isn’t easily modifiable by mucking with the URL hash.