AngularJS: 在客户端显示 JSON 对象内容

AngularJS: Displaying JSON Object Content on Client Side

我正在尝试显示 JSON 对象的内容。在客户端,我使用 ng-repeat 遍历对象名称 Users 以获取 ID、名称和密码。但是,我只在客户端得到'[object Object] 而不是预期值。

//The controller that I am using
 myApp.controller('userController', function ($scope,$http /*UserService*/) {
      //  $scope.Users = [];
        $http.get('/Templates/ListUsers')
        .success(function (data) {
            // $scope.Users = data.data;
            if (data.Ok) {
                $scope.Users = JSON.stringify(data.data);
                console.log($scope.Users);
            }
        }).error(function(error){
            console.log(error);
        });

//The form where the data is supposed to display. 

<div class="row">
       <div class="form-group">
           <li ng-repeat="x in Users"> 
               {{ x.ID, x.Name, x.Password  }}
           </li>
       </div>
   </div>   

//The JSON object based on the line console.log($scope.Users);
{"Ok":true,"data":[{"ID":1,"Name":"Name1","Password":"Password1"}, 
{"ID":2,"Name":"Name2","Password":"Password2"}
,{"ID":3,"Name":"Name3","Password":"Password3"},
{"ID":4,"Name":"Name4","Password":"Password4"}],"message"
 :"Success"}

下面是 plunker 中的相同示例,并且有效。

http://plnkr.co/edit/btL2QMyHxhDLH7cxZ1YV?p=info

你不应该 stringify JSON。

$scope.Users = data.data;

您应该在显示输出时使用 string 连接。

<li ng-repeat="x in Users"> 
     {{ x.ID +','+ x.Name +','+ x.Password  }}
</li>