启动Angular.js线路段或UI路由器毕竟是翻译装 [英] Start Angular.js route-segment or ui-router after all translations are loaded
问题描述
有什么办法,如何启动UI路由器或路由段translateProvider加载其翻译刚过?
Is there any way, how to start ui-router or route-segment just after translateProvider loads its translations?
我用帕斯卡尔prechts使用绑定一次{{::}}符号一起翻译过滤器。在本地主机上它的工作原理pretty不错,但是当我测试它远程服务器上,一旦绑定将删除观察家早于字符串进行翻译。
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),调用在配置时此方法。然后,在运行时,调用 $ urlRouter.listen()
您已经配置了自己的 $ locationChangeSuccess
事件处理程序之后。
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.
查了一些类似的问题:
- AngularJS - UI-router - How to configure dynamic views
- can we add dynamic states to $stateprovider with already existing states in ui-router angular.js
在其中一个链接,遵守本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 hanlding上
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线路段或UI路由器毕竟是翻译装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!