Start Angular.js route-segment or ui-router after all translations are loaded

耗尽温柔 提交于 2019-11-28 14:30:51
Radim Köhler

Try to check the native, built-in feature:

$urlRouterProvider.deferIntercept(defer)

Disables (or enables) deferring location change interception.

If you wish to customize the behavior of syncing the URL (for example, if you wish to defer a transition but maintain the current URL), call this method at configuration time. Then, at run time, call $urlRouter.listen() after you have configured your own $locationChangeSuccess event handler.

Check some similar issues:

In one of these links, observe this plunker, where this feature is used like this:

Stop and wait in .config() phase:

.config(['$urlRouterProvider' ...,
    function($urlRouterProvider, ...) {

      // defer execution in config phase
      $urlRouterProvider.deferIntercept();
      ...

Later in .run() phase turn the url hanlding on

.run(['$urlRouter' ...,
  function($urlRouter...) {
    ...
    $http
      .get("modules.json")
      .success(function(data) {

        // do some stuff
        // re-enable UI-Router url stuff

        $urlRouter.sync();
        $urlRouter.listen();

      });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!