在 angular js 中从 ng-repeat 输入设置 ng-model 值?

Set ng-model value from ng-repeat input in angular js?

我试图让客户使用 ngRepeat 和 ngModel 编辑项目列表。但我无法设置对输入字段的响应 这是代码。

<form name="customerupdateForm" ng-submit="EditCustomerSubmit(updatecustomer)" class="horizontal-form">                             
    <div class="row-fluid" ng-repeat="updatecustomer in itemList">
        <div class="control-group">
        <label class="control-label">Customer Name</label>
        <input type="text" name="customer_name" ng-model="updatecustomer.customer_name" class="span6 m-wrap"/>                                          
        </div>
        <!--/span-->
        <div class="control-group">
        <label class="control-label">Company Name</label>
        <input type="text" name="company_name" ng-model="updatecustomer.company_name" class="span6 m-wrap"/>                                            
        </div>
    </div>
</form>

Angular.js

$scope.id = $routeParams.id;

$scope.getupdateCustomerdata = function(id){
    $http({
        method: 'get',
        url: 'api/master/customer/getupdatecustomer?id=' + $routeParams.id
    }).then(function successCallback(response) {

        console.log(response.data['customer_name']);
        $scope.updatecustomer = {};
        //set response to input filed
        $scope.updatecustomer.customer_name = response.data['customer_name'];
    }); 
}
$scope.getupdateCustomerdata();

我假设您的 api 返回给您 Customers 的列表,在这种情况下,您必须使 api 响应等于 itemList angularjs

.then(function successCallback(response) {

    console.log(response.data['customer_name']);
    $scope.updatecustomer = {};
    //set response to input filed
    $scope.itemList = response;
});

如果您的响应是一个对象列表并且具有名为 customer_namecompany_name 的属性,那么您的输入元素将填充模型值