ui-router 动态路由问题

ui-router Dynamic routing issue

是否使用angularJS 1.5 和ui.router 来动态定义状态和路由? 我的意思是从后端服务器获取数据,然后填充 ui-router 参数,例如状态,URL ... 我尝试使用将它们放在 运行 部分,但它不起作用,因为从服务器检索的数据在需要时不可用。这就是我正在做的

run(
  function run(Idle, $http, $q, $state, $rootScope) {
    Idle.watch();
    $urlRouterProviderRef.otherwise('/login');

    $urlRouterProviderRef.when("", "/login");
    $http.get(_contextPath + '/routing', {})
    .success(function(data)
    {
        $rootScope.LOGIN_PAGE_CONTROLLER_NAME = data.LOGIN_PAGE_CONTROLLER_NAME;
        $rootScope.LOGIN_PAGE_PAGE_TITLE = data.LOGIN_PAGE_PAGE_TITLE;
        $rootScope.LOGIN_PAGE_STATE = data.LOGIN_PAGE_STATE;
        $rootScope.LOGIN_PAGE_TEMPLATE_URL = data.LOGIN_PAGE_TEMPLATE_URL;
        $rootScope.LOGIN_PAGE_URL = data.LOGIN_PAGE_URL;


    });

    var test = $rootScope.LOGIN_PAGE_STATE;

        $stateProviderRef.state($rootScope.LOGIN_PAGE_STATE, {
            url : $rootScope.LOGIN_PAGE_URL,
            views : {
                "mainbody" : {
                    templateUrl : $rootScope.LOGIN_PAGE_TEMPLATE_URL
                },

            },
            controller : $rootScope.LOGIN_PAGE_CONTROLLER_NAME,
            data : {
                pageTitle : $rootScope.LOGIN_PAGE_PAGE_TITLE,
                authenticate : false
            }
        });
})

非常感谢任何帮助

这里描述了要走的路

AngularJS - UI-router - How to configure dynamic views

一段代码:

var app = angular.module('app', ['ui.router.router']);

app.config(function($urlRouterProvider) {

  // Prevent $urlRouter from automatically intercepting URL changes;
  // this allows you to configure custom behavior in between
  // location changes and route synchronization:
  $urlRouterProvider.deferIntercept();

}).run(function($rootScope, $urlRouter, UserService) {

  $rootScope.$on('$locationChangeSuccess', function(e) {
    // UserService is an example service for managing user state
    if (UserService.isLoggedIn()) return;

    // Prevent $urlRouter's default handler from firing
    e.preventDefault();

    UserService.handleLogin().then(function() {
      // Once the user has logged in, sync the current URL
      // to the router:
      $urlRouter.sync();
    });
  });

  // Configures $urlRouter's listener *after* your custom listener
  $urlRouter.listen();
});

检查更多和工作 plunker there