2016-06-28 57 views
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> 

这是客户端的代码。

任何方式把这些东西推到一起......

回答

1

您只需通过创建

var quantity = ItemsValue[1]; 
$scope.product = []; 
$http.get(___).success(function(data) { 
    $scope.greeting = data; 
    $scope.greeting.quantity = quantity; 
    $scope.product.push($scope.greeting); 
} 
+0

我使用鉴于问候显示数据 –

+0

@ZiaUllahMinhas一个新的属性将其添加到该对象相应地修改 – Icycool

+0

非常感谢@cycyol –

相关问题