angularjs - How to validate state with angular ui-router -
we're using angular-ui-router (version 0.2.10 believe).
there 2 primary ways arrive @ state,
- a) user hits / ammends url corresponds state
- b) code somewhere e.g. controller invokes $state.go().
we in case a) validate state (e.g. valid according 1 or more business rules), not in case b) since we're pretty sure our application transition valid states.
case a) require http round trip perform validation we'd avoid if possible.
how implemented?
thanks!
you wrap validation in service , call every time state changes. however, before moving state $state.go(), instruct validation service consider particular parameters passing valid. e.g.
validationservice.trustasvalid(yourdata);
Comments
Post a Comment