加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 有没有办法在AngularUI路由器中的任何子解析之前解

发布时间:2020-12-17 08:47:10 所属栏目:安全 来源:网络整理
导读:我在coffeescript中有2个州…… stateProvider.state 'test',... resolve: user: (LongRunning)- LongRunning.authenticate().then - console.log("We are authenticated!")stateProvider.state 'test.child',... resolve: other: (AfterAuth)- AfterAuth.so
我在coffeescript中有2个州……
stateProvider.state  'test',...
    resolve:
        user: (LongRunning)->
            LongRunning.authenticate().then ->
                console.log("We are authenticated!")

stateProvider.state  'test.child',...
    resolve:
        other: (AfterAuth)->
            AfterAuth.soSomethingWithAuth().then ->
                console.log("We are done!")

当然这不起作用,因为在解析父级的auth方法之前启动了子解析.这意味着第二个函数将不会被验证并导致整个状态失败.

现在它不一定是状态路径的一部分,但它需要在调用resolve函数时完全完成.

在调用child中的方法之前,如何确保完全解析父函数?

坏(?)解决方案

我能够提出的一个答案是使用手动引导程序.然而,这是乏味的,因为我需要重新连接我的所有服务.无论如何我可以在Angular中做到吗?

你是使用AngularUI Router for Angular 2还是AngularJS?我认为AngularJS就是你使用coffeescript和AngularUI Router的事实.这是Angular标签而不是AngularJS.

无论如何在AngularUI路由器中,一个解析器可以依赖于另一个.像这样的东西:

function firstStep($stateParams,resolveStatus) {
   return $q.resolve();
 }

 resolve: {
   firstStep: firstStep,secondStep: ['firstStep',function (firstStep) {
   ...
   }]
 }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读