无法将document.getElementById值分配给ng-repeat中的ng-model

时间:2018-02-23 11:30:14

标签: javascript html angularjs



<select class="form-control" name="suppliername" ng-model="suppliername"  data-ng-change="supplier_data1(suppliername)" required>
 <option value="">Select</option>
 <option ng-repeat="custids in supp_nmArray" value="{{custids.Supplier_Id}}"  >{{custids.name}} 
 </option>                                                       
</select>

<table class="table table-striped" >
    <thead>
    <tr>
        <th>Product Name</th>
        <th>Qty</th>
        <th>Rate</th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="p in products">
        <td>{{ p.Product_Name }}

            <input type="hidden" class="form-control" name="sname" ng-model="sname" required>

        </td>
        <td>
            <input type="text" class="form-control" name="finalqty" ng-model="p.finalqty"  ng-change="change_qty(p.productrate,p.finalqty)"/>
        </td>
        <td>
            <span ng-init="GetProdcutDetails(p.Product_Name,sname,'productrate'+$index)"></span>
            <input type="text" class="form-control" name="purches_rate" ng-model="p.purches_rate" id="productrate{{$index}}">
        </td>
    </tr>
    </tbody>
</table>
&#13;
&#13;
&#13;

&#13;
&#13;
var app=angular.module("myapp",['ui.bootstrap']);
app.controller("ctrl",function($scope,$http)
{
 

     $scope.supplier_data1 = function(suppliername)
  {
      $scope.sname=suppliername;
  }
  $scope.GetProdcutDetails = function(Product_Name,sname,productrate)
  {
    $http.post("get_prodcut_rate.php",{'Product_Name':Product_Name,'suppliername':$scope.sname})
        .success(function(data)
        {
          var x = document.getElementById(productrate);
          document.getElementById(productrate).value = data[0].purches_rate;
        });
  }
});
&#13;
&#13;
&#13;

我通过使用javascript(getElementById)获得ng重复的产品价值。

如何在ng-repeat中将document.getElementById分配给ng-model?

我需要在另一个函数中传递值。 kinldy帮助我

先谢谢你。

0 个答案:

没有答案