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

前端 未结 1 1242
面向向阳花
面向向阳花 2020-12-12 04:28

Is there any way, how to start ui-router or route-segment just after translateProvider loads its translations?

I\'m using pascal prechts translate filter together wi

相关标签:
1条回答
  • 2020-12-12 04:50

    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:

    • AngularJS - UI-router - How to configure dynamic views
    • can we add dynamic states to $stateprovider with already existing states in ui-router angular.js

    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();
        
          });
    
    0 讨论(0)
提交回复
热议问题