0
我目前正在研究一個項目,其中,我從服務器獲取數據並在數組中添加(推送)以進一步處理。它的工作很棒。 當我使用來自服務器的數據將外部數據添加到數組時,我面臨問題。用數據從服務器到數組推送extenal數據
var quantity= ItemsValue[1];
$scope.product = [];
$http.get(___).success(function(data) {
$scope.greeting = data ;
$scope.product.push($scope.greeting);
}
我想用「$ scope.greeting」來推送「數量」。我已經嘗試了不同的事情,例如串接,但失敗了。
我想要數組的數據是這樣的。對於實施例
$ scope.product = [{ 「greeting.name」: 「ABC」, 「greeting.price」: 「50」, 「量」: 「1」}]
名稱和價格來自服務器,數量作爲額外數據添加到數組中。
<tbody >
<tr ng-repeat="greeting in product" ><!-- -->
<td class="cart_product">
<img src={{greeting.Image}} alt="book image" ></td>
<td class="cart_description">
<h4>{{greeting.Name}}</h4></td>
<td class="cart_price">
<p>Rs. {{greeting.Cost}}</p>
</td>
<td class="cart_quantity">
<div class="cart_quantity_button">
<a class="cart_quantity_up" href=""> + </a>
<input class="cart_quantity_input" type="text" name="quantity" value="Itemsquantity" autocomplete="off" size="2">
<a class="cart_quantity_down" href=""> - </a>
</div>
</td>
<td class="cart_total">
<p class="cart_total_price">Rs. {{greeting.Cost}}</p>
</td>
<td class="cart_delete">
<a class="cart_quantity_delete" ng-click="removeItem($index)"><i class="fa fa-times"></i></a>
</td>
</tr>
</tbody>
這是客戶端的代碼。
任何方式把這些東西推到一起......
我使用鑑於問候顯示數據 –
@ZiaUllahMinhas一個新的屬性將其添加到該對象相應地修改 – Icycool
非常感謝@cycyol –