How to check status using angular ui-router

We use angular -ui-router (version 0.2.10, I believe).

There are two main ways to achieve a state,

  • a) the user removes / changes the URL corresponding to the state
  • b) code somewhere, for example. the controller calls $ state.go ().

We would like to a) check the state (for example, it operates in accordance with one or more business rules), but not do this in case b), since we are sure that our application will only transition to valid states.

Case a) often requires a round trip to carry out a check that we would like to avoid, if possible.

How will this be implemented?

Thanks!

+5
source share
1 answer

You can wrap the check in the service and call it every time a state changes. However, before going to another state with $state.go() you tell the validation service to consider the specific parameters that you pass as valid. For instance.

 validationService.trustAsValid(yourData); 
0
source

Source: https://habr.com/ru/post/1200641/


All Articles