我在角应用程序中使用ui路由器,我希望从服务器获取ui路由器的状态通过以json格式返回状态列表的调用操作然后在stateProvider中设置状态列表项,怎么能&我这样做的代码是app.Config for config state:
var list = ?????// how can get state list here?
var populateStates = function () {
angular.forEach(list, function(item) {
$stateProvider.state(item);
};
};
populateStates();
答案 0 :(得分:3)
简单样本:
var list = [['home', {
url: '/',
templateUrl: '/views/index',
controller: 'HomeCtrl'
}],
['about', {
url: '/about',
templateUrl: '/views/about',
controller: 'AboutCtrl'
}]];
var populateStates = function () {
angular.forEach(list, function(item) {
$stateProvider.state(item[0], item[1]);
};
};