1

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 with bind once {{:: }} notation. On localhost it works pretty good, but when I test it on remote server, bind once will remove watchers sooner than strings are translated.

So I was wondering if there is some way how to delay routing a little bit.

Jan Jůna
  • 4,965
  • 3
  • 21
  • 27

1 Answers1

2

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();
    
      });
Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • I have found few more plunkers, like this one: http://plnkr.co/edit/VLS45S0TYSlwZVJ3Wg4g?p=preview where it is used.. It works for small $timeout like 20'000ms but when I put there 60'000ms routing won't start.. Also I didn't found anything like this for route-segment-provider which we are using in our app.. But for small timeouts (or in our case loading initial files) it will be good enought.. thank you – Jan Jůna May 28 '15 at 11:03
  • 1
    Great, ... if that helped anyhow. Enjoy amazing UI-Router, Honzo ;) – Radim Köhler May 28 '15 at 11:04