THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
It seems to me this is supposed to read "If the state is not defined, then register the state", but that is not what the logic accomplishes.
state && (!$state.get(state) || (state.name && !$state.get(state.name))) says "If the state is not defined by reference or the state is not defined by name, then register the state". The guard will pass if the state is not found by reference and it will incorrectly attempt to register an existing state. The logic should be state && !($state.get(state) || (state.name && $state.get(state.name))).
I ran into an issue where ui-router was throwing a "State [name] is already defined" error. In trying to figure out why there was an attempt to redefined the same state, I traced it to the following line: https://github.com/christopherthielen/ui-router-extras/blob/master/src/future.js#L189. The same guard is repeated here: https://github.com/christopherthielen/ui-router-extras/blob/master/src/future.js#L238.
It seems to me this is supposed to read "If the state is not defined, then register the state", but that is not what the logic accomplishes.
state && (!$state.get(state) || (state.name && !$state.get(state.name)))
says "If the state is not defined by reference or the state is not defined by name, then register the state". The guard will pass if the state is not found by reference and it will incorrectly attempt to register an existing state. The logic should bestate && !($state.get(state) || (state.name && $state.get(state.name)))
.