我在app.run
中动态加载状态(基于服务器调用)。window.$stateProviderRef
只是对在$stateProvider
的窗口对象上设置的app.config(..)
的引用
app.run(function($http) {
$http.get('/api/states').
success(function(data, status, headers, config) {
angular.forEach(data, function(state) {
window.$stateProviderRef.state(state.name, { url: state.url, templateUrl: state.templateUrl) : state.templateUrl });
});
});
});
是否可以通过某种方式清除或重新加载状态配置?这样以前的状态无效并加载了新的状态?
最佳答案
目前实际上是不可能的,但是在Angular路线图中,您可以在此处跟上进度https://github.com/angular-ui/ui-router/issues/1095