AngularJS - $resource + ng-repeat 问题

AngularJS - $resource + ng-repeat issue

在我的 html 文件中我有以下 table:

<div ng-controller="InstructorCtrl">
    <table class="table table-bordered">
      <thead>
        <tr>
          <th>Title</th>
          <th>Name</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="instructor in instructors">
          <td>{{instructor.title}}</td>
          <td>{{instructor.name}}</td>
        </tr>
      </tbody>
    </table>
</div>

控制器的外观如下:

angular.module('angularFrontendApp')
  .controller('InstructorCtrl', function ($scope, Instructor) {
    $scope.instructors = [];
    $scope.instructors = Instructor.query();
  });

注入Instructor是工厂:

angular.module('angularFrontendApp')
  .factory('Instructor', function ($resource) {
    return $resource('http://localhost:9000/api/instructor');      
  });

大多数时候 table 渲染得很好:

但我注意到,当我重新加载页面几次时,table 有时看起来像这样:

我还以为是ng-repeat开球时$resource$promise开球了,问题还是没有解决。所以我在 returns instructors 列表的后端方法中设置了断点。当执行停止时,页面上只呈现 table header。当继续执行并从服务器发送数据时,table 呈现得很好。我觉得很奇怪。

感谢您的回答。

我仔细查看了后端调用了哪些方法。它实际上是一个罕见的服务器端问题,导致路由混乱。