简体   繁体   English

如何始终显示来自对象的html中的值?

[英]How to show values in html coming from object consistently?

My html : 我的html:

<p ng-repeat="gg in john(z.items)">Item:{{gg.name}}  Quantity:{{gg.quantity}}</p>

My controller: 我的控制器:

 $http.get('/api/restros/myorders').success(function(val){
      console.log("my orders:");
      console.log(val);
      var temp=[];
      $scope.mydata=val;
      $http.get('/api/restros/').success(function(data){
        $scope.john=function(parent){
          console.log("parent");
          console.log(parent);
          for(var i=0;i<parent.length;i++){
            temp=[];
            for(var j=0;j<data.length;j++){
              if(data[j]._id==parent[i].id){
                temp.push([{name:data[j].name,quantity:parent[i].quantity,rate:data[j].rate}]);
              }
            }
              console.log(typeof (temp[0]));
          }
        }
      });
    });

Now I want to show the response in the console like so: 现在,我想在控制台中显示响应,如下所示:

Object: {name: "Beef Burger", quantity: 1, rate: 150} 对象: {name: "Beef Burger", quantity: 1, rate: 150}

Object: {name: "Maharaja Mac", quantity: 1, rate: 150} 对象: {name: "Maharaja Mac", quantity: 1, rate: 150}

Z.items是我要解析的项目,它们来自我公司提供给我的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript object 不存储来自 HTML 的数据 - Javascript object not storing data coming from HTML 如何更改嵌套数组中对象的值 - how to chnage values of object coming in nested array 如何使用模板文字和来自 JavaScript 中的对象文字的数据生成 HTML? - How to generate HTML using template literal with data coming from an object literal in JavaScript? 如何修复进入HTML下拉列表的JSON代码作为对象Object - How to fix json code coming into html dropdown as object Object 如何解构来自 useFetch 的 object? - how to deconstruct an object that is coming from useFetch? 在以POST(而不是GET)发送请求后,如何将对象作为html页面插入到来自后端的html元素中? - How to insert object as html page into html element which is coming from back-end after sending request as POST (and not GET)? 用来自 JSON 对象的占位符值替换字符串 - Substitute string with placeholder values coming from JSON object 如何显示HTML中来自数据库的数据的两个值? - How can i show two values of data from database in html? 如何将来自 postman 的 object 推送到嵌套的 object? - How to push an object coming from postman to nested object? 来自不同页面时如何显示/隐藏单个元素? - how to show/hide the single element when coming from different pages?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM