0
我的HTML:如何在來自對象的HTML中一致地顯示值?
<p ng-repeat="gg in john(z.items)">Item:{{gg.name}} Quantity:{{gg.quantity}}</p>
我的控制器:
$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]));
}
}
});
});
現在我想表明,像這樣在控制檯響應:
對象:{name: "Beef Burger", quantity: 1, rate: 150}
對象:{name: "Maharaja Mac", quantity: 1, rate: 150}
你爲什麼不使用角度的ng-repeat? –
什麼是z.items? – defaultcheckbox
Z.items是我想要解析的項目,它們來自我公司提供給我的API。 –