AngularJS:UI-Router空白页调试

时间:2021-10-07 10:56:13

I just wondering does anybody know how to debug situation when you have blank page for UI-Router. (Of course, without any errors in console)

我只是想知道当你有UI-Router的空白页时,有没有人知道如何调试情况。 (当然,在控制台中没有任何错误)

By doing console.log for router events(take from here) I found you that it went to correct state but after did not stop on breakpoint inside state controller that I specified in UI-Router state:

通过对路由器事件执行console.log(从这里开始),我发现它进入了正确的状态但是在我在UI-Router状态中指定的状态控制器内的断点没有停止:

.state('invited-user', {
   parent: 'authPublic',
    url: '/users/invitation/accept?back_link&invitation_token',
    templateUrl: 'auth/invited-form.html',
    controller: 'InvitedUserController',
    data: {
      hidePageNavigation: true
    }
}) 

so I guess that controller is a problem. Already tried to mock it:

所以我猜控制器是个问题。已经试图嘲笑它:

.state('invited-user', {
   parent: 'authPublic',
    url: '/users/invitation/accept?back_link&invitation_token',
    templateUrl: 'auth/invited-form.html',
    controller: function(){
      debugger
    },
    data: {
      hidePageNavigation: true
    }
})  

but without any result, unfortunately.

但遗憾的是没有任何结果。

I look for solution for current issue and general approach how to debug such kind of situations in general.

我寻找当前问题的解决方案和一般方法如何调试这种情况。

1 个解决方案

#1


4  

So I came to conclusion that the logic of debug should be so:

所以我得出结论,调试的逻辑应该如此:

  1. console.log router events (code is here) to check router logic
  2. console.log路由器事件(代码在这里)检查路由器逻辑

  3. check the template of current router state (mock it if needed)
  4. 检查当前路由器状态的模板(如果需要,模拟它)

  5. check the controller of current state (mock with empty function if needed)
  6. 检查当前状态的控制器(如果需要,使用空函数模拟)

  7. check all templates and controllers of parent states from current one, starting from nearest parent and going up.
  8. 从最近的父项开始检查父状态的所有模板和控制器,从最近的父项开始。

Actually it would be nice to have exception from box to see exact problem, but unfortunately we have what we have.

实际上,从盒子中获取异常以查看确切的问题会很好,但不幸的是我们拥有了我们拥有的东西。

#1


4  

So I came to conclusion that the logic of debug should be so:

所以我得出结论,调试的逻辑应该如此:

  1. console.log router events (code is here) to check router logic
  2. console.log路由器事件(代码在这里)检查路由器逻辑

  3. check the template of current router state (mock it if needed)
  4. 检查当前路由器状态的模板(如果需要,模拟它)

  5. check the controller of current state (mock with empty function if needed)
  6. 检查当前状态的控制器(如果需要,使用空函数模拟)

  7. check all templates and controllers of parent states from current one, starting from nearest parent and going up.
  8. 从最近的父项开始检查父状态的所有模板和控制器,从最近的父项开始。

Actually it would be nice to have exception from box to see exact problem, but unfortunately we have what we have.

实际上,从盒子中获取异常以查看确切的问题会很好,但不幸的是我们拥有了我们拥有的东西。