我想将多个克隆输入字段保存到数据库中,但是我无法保存它。 我们已经正确地克隆和删除了输入文件,但是克隆了输入字段,而不是将数据传递给ng模型,请帮助我在单击angular js中的ng-submit时如何将数据保存和传递给ng模型
Form.html
<form name="customeraddForm" ng-submit="addCustomerSubmit(addcustomer)" class="horizontal-form">
<div class="tab-content">
<div class="tab-pane " id="tab_2">
<div ng-repeat="addcustomer in fieldGroups0" class="well">
<div class="control-group" ng-init="name = 'Value[block]'">
<div class="control-group">
<label class="control-label">Address Type</label>
<div class="controls">
<select ng-model="addcustomer.select4" name="{{ getName($index) }}" type="text" class="span6 m-wrap">
<option value="">Select</option>
<option value="Sample 1">Billing</option>
<option value="Sample 2">Shipping</option>
</select>
</div>
</div>
<!--/span-->
<div class="control-group">
<label class="control-label">Address</label>
<div class="controls">
<textarea ng-model="addcustomer.address" name="{{ getName($index) }}" type="text" class="span6 m-wrap" rows="3">
</textarea>
</div>
</div>
</div>
<a ng-click="delete0()" class="btn btn-danger btn-sm">Remove Address</a>
<a ng-click="clone0()" class="btn btn-primary">Add New Address</a>
</div>
</div>
</div>
<a ng-click="delete1()" class="btn btn-danger btn-sm">Remove Clone Business</a>
<a ng-click="clone1()" class="btn btn-primary">Clone Business</a>
</div>
</div>
<!-- End Tab 4 -->
</div> <!-- tab-content -->
<div class="form-actions">
<button type="submit" name="customer_submit" class="btn blue">Add</button>
<button type="button" name="customer_cancel" class="btn">Cancel</button>
</div>
</form>
<!-- END FORM-->
Angular.js
angular.module('Test')
.controller('TestCtrl', ['$rootScope','$scope','$http','$location','$routeParams',
function ($rootScope,$scope,$http,$location,$routeParams) {
$scope.fieldGroups = [
{
'select4': '',
'address': '',
}
];
$scope.getName = function ( $index) {
return $scope.name + '[' + $index + ']';
}
$scope.clone = function() {
$scope.fieldGroups.push({});
}
$scope.delete = function(fieldGroup) {
var index = $scope.fieldGroups.indexOf(fieldGroup);
console.log(index);
}
//save customer data after submit function start
$scope.addCustomerSubmit = function(customerData){
console.log(customerData);
}
//End
}]);