Javascript 显示对象数组中的值AngularJS

Javascript 显示对象数组中的值AngularJS,javascript,angularjs,Javascript,Angularjs,有人能帮我咬一下吗 问题是,我对订单的服务器字符串,数组有res 排列 [对象,对象,对象] 并希望逐个显示所有对象中的项目值 例如: 控制器: $scope.ListOfOrders = function () { return ApiService.cart.list($scope.user).then(function (resp) { $scope.orders = JSON.parse(resp[0].order); console.log(re

有人能帮我咬一下吗

问题是,我对订单的服务器
字符串
数组
有res 排列

[对象,对象,对象]

并希望逐个显示所有对象中的项目值 例如:

控制器:

$scope.ListOfOrders = function () {
    return ApiService.cart.list($scope.user).then(function (resp) {
        $scope.orders = JSON.parse(resp[0].order);
        console.log(resp)
    });
}
{{orders}}

>  [{"_id":"596f39515156f6178cbf3721","order":"[{\"item\":\"DELL\",\"quantity
> \":6,\"price\":144},{\"item\":\"ziemniaki\",\"quantity\":3,\"price\":3131},
> {\"item\":\"Wisnie\",\"quantity\":1,\"price\":31},{\"item\":\"111111111\",\"quantity\":1,\"price\":13}]","price":10301,"client":"q","IDclient":"5969ef800151e63ce01ec50c","__v":0,"created":"2017-07-19T10:49:53.061Z","updated":"2017-07-19T10:49:53.061Z"},{"_id":"597085de1d3e9722385773a8","order":"[{\"item\":\"ziemniaki\",\"quantity\":2,\"price\":3131},{\"item\":\"Wisnie\",\"quantity\":5,\"price\":31}]","price":6417,"client":"q","IDclient":"5969ef800151e63ce01ec50c","__v":0,"created":"2017-07-20T10:28:46.591Z","updated":"2017-07-20T10:28:46.591Z"},{"_id":"597086e41d3e9722385773a9","order":"[{\"item\":\"ziemniaki\",\"quantity\":2,\"price\":3131},{\"item\":\"Wisnie\",\"quantity\":5,\"price\":31}]","price":6417,"client":"q","IDclient":"5969ef800151e63ce01ec50c","__v":0,"created":"2017-07-20T10:33:08.444Z","updated":"2017-07-20T10:33:08.444Z"}]

您可以根据需要修改数据-

就像你能做到一样

var newOrders=[]
angular.forEach(orders,function(value,key){
  var obj={};
  obj.Ordername="Order"+key;
  obj.values=[];
 angular.forEach((value.order),function(v,k){
   obj.values.push(v.item);
})
newOrders.push(obj);
})
现在,您可以随意使用此
newOrder


希望它能对您有所帮助。

您可以将项目从响应筛选到显示-

app.controller('orderCtrl', ['$scope', 'ApiService', '$filter', 
  function(s, ApiService, $filter) {

  s.newOrders = [];

  //Function to get the order response
  s.ListOfOrders = function () {
        return ApiService.cart.list(s.user).then(function (resp) {
            s.orders = JSON.parse(resp[0].order);
            //Now everything in orders
            s.orders.forEach(function(o) {
              s.newOrders.orderName="Order"+key;
              s.newOrders.items = o.filter(function(r) { return r.item })
                  console.log(s.newOrders )
            })

        });
    }
}])
//在html模板中

<div ng-repeat="order in newOrders">
  <span>order.orderName</span>
  <div ng-repeat="item in order.items">
    {{item}}
  </div>
</div>

order.orderName
{{item}}

JSON.parse(resp)[0]。顺序要显示在何处?如果我对resp[0]进行解析,并且首先获得order only nr:(,我需要全部。我想在视图html中显示。现在呢??:
<div ng-repeat="order in newOrders">
  <span>order.orderName</span>
  <div ng-repeat="item in order.items">
    {{item}}
  </div>
</div>