javascript – 加载所有翻译后启动Angular.js route-segment或ui-router
作者:互联网
有没有办法,如何在translateProvider加载其翻译后启动ui-router或route-segment?
我正在使用pascal prechts翻译过滤器和绑定一次{{::}}表示法.在localhost上它工作得很好,但是当我在远程服务器上测试它时,绑定一次将比字符串翻译更快地删除观察者.
所以我想知道是否有一些方法如何延迟路由一点点.
解决方法:
尝试检查本机内置功能:
$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.
检查一些类似的问题:
> AngularJS – UI-router – How to configure dynamic views
> can we add dynamic states to $stateprovider with already existing states in ui-router angular.js
在其中一个链接observe this plunker中,此功能的使用方式如下:
停止并等待.config()阶段:
.config(['$urlRouterProvider' ...,
function($urlRouterProvider, ...) {
// defer execution in config phase
$urlRouterProvider.deferIntercept();
...
稍后在.run()阶段转动url hanlding
.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-translate,javascript,angularjs,angular-ui-router 来源: https://codeday.me/bug/20190929/1833807.html