Html bootstrap table 未出现在屏幕上

Html bootstrap table not appearing on screen

我无法在 html 中显示 table。当我在 table 中对值进行硬编码时,它们会出现,但在使用 angularjs 时它们不会出现。所以我认为这个问题与 angualrjs 中的某些东西有关。这是我要显示的 html 代码:

 <div class="container">
 <h2>Hover Rows</h2>
 <p>The .table-hover class enables a hover state on table rows:</p>            
 <table class="table table-hover">
 <thead>
  <tr>
    <th>Friends</th>
  </tr>
 </thead>
 <tbody>
    <tr ng-repeat="Friends in AllUsersFriends">
        <td>{{Friends}}</td>
  </tr>
 </tbody>
 </table>
 </div>

这是我的 controller.js 代码:

    socket.on("AllFriends",function (Friends){
  $log.log('so the friends are');
  $scope.AllUsersFriends=Friends;
  console.log($scope.AllUsersFriends);
  $scope.$apply();
});

我正在通过 flask-socketio 接收一个数组,然后将该数组设置为我创建的 $scope.AllUsersFriends 数组。我在控制台中看到了数据,但屏幕上没有显示任何行。如何让我的数据显示在屏幕上?谢谢。

看看这个:

<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">

 <table class="table table-hover">
    <tr><th>Friends</th></tr>
    <tr ng-repeat="x in friends"><td>{{x.name}}</td></tr>
 </table>

<script>
//App declaration
var app = angular.module('myApp',[]);
//Controller Declaration
app.controller('myCtrl',function($scope){
    $scope.friends = [{name: "Peter"},{name:"Laila"},{name:"Rosy"}];

});

</script>
</body> 
</html> 

希望,解决了!

所以我解决了我的问题,问题是数组中的数据实际上正在更新,但我的应用程序中有不同的页面,一旦我更改页面,数据就会丢失然后我通过创建解决了它服务中的相同阵列,以便更改是全局的,数据不会从阵列中擦除。所以 table 总是显示它只是没有任何数据可显示。 非常感谢