Here is the use case. Given a stateConfig object, I can access state.url
, but this only returns the URL specified in that configuration object, not the URL that in
Got it.
After a bit of logging, i realized that calling state.$$state()
will return the wrapped state config object.
You can expose the internal state implementation by using the .decorator
hook on $stateProvider
. You can decorate any property of the state builder; I chose 'parent' arbitrarily.
app.config(function($stateProvider) {
$stateProvider.decorator('parent', function (internalStateObj, parentFn) {
// This fn is called by StateBuilder each time a state is registered
// The first arg is the internal state. Capture it and add an accessor to public state object.
internalStateObj.self.$$state = function() { return internalStateObj; };
// pass through to default .parent() function
return parentFn(internalStateObj);
});
});
Now you can access the internal state object using .$$state()
, e.gg
var publicState = $state.get("foo");
var privateInternalState = publicState.$$state();