加载所有翻译后启动 Angular.js route-segment 或 ui-router [英] Start Angular.js route-segment or ui-router after all translations are loaded

查看:20
本文介绍了加载所有翻译后启动 Angular.js route-segment 或 ui-router的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,如何在 translateProvider 加载其翻译后立即启动 ui-router 或 route-segment?

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

我正在使用 pascal prechts translate 过滤器和 bind once {{:: }} 符号.在本地主机上它工作得很好,但是当我在远程服务器上测试它时,绑定一次将在字符串翻译之前删除观察者.

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.

推荐答案

尝试检查原生、内置功能:

Try to check the native, built-in feature:

禁用(或启用)延迟位置更改拦截.

Disables (or enables) deferring location change interception.

如果您希望自定义同步 URL 的行为(例如,如果您希望延迟转换但保留当前 URL),请在配置时调用此方法.然后,在运行时,在您配置自己的 $locationChangeSuccess 事件处理程序后调用 $urlRouter.listen().

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.

检查一些类似的问题:

在这些链接之一中,观察这个 plunker,其中使用了此功能像这样:

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

.config()阶段停止并等待:

Stop and wait in .config() phase:

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

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

稍后在 .run() 阶段打开 url 处理

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();
    
      });

这篇关于加载所有翻译后启动 Angular.js route-segment 或 ui-router的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆