I am trying to display the content of a JSON object. On the client side, I am using ng-repeat to iterate through the object name Users to get the ID, Name, and Password. However, I am only getting '[object Object] on the client side instead of the expected values.
//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"}
Below is the same example in plunker, and it works.