您可以通過使用.decorator
鉤上$stateProvider
暴露內部狀態的實現。你可以裝飾國家建設者的任何財產;我任意選擇了「父母」。
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);
});
});
現在,您可以訪問使用.$$state()
內部狀態的對象,e.gg
var publicState = $state.get("foo");
var privateInternalState = publicState.$$state();
克里斯你是一個芭蕾舞者。非常感謝。 – Derek 2014-11-11 04:50:39