我想为angularjs中的动态行生成Json数据,我为每个输入标记使用了ng-model。
<form name="userForm3" ng-submit="submit()">
<tr ng-repeat="item in invoice.items">
<td><select ng-options="item as item.name for item in invoice.items[0].loyality " name="item.loyality" ng-model=" form3.loyality" required></select></td>
<td><input type="text" name="item.value" ng-model="form3.value" required style="width:100px"></td>
<td><select ng-options="item as item.name for item in invoice.items[0].period " name="item.period" ng-model= " form3.period" required ></select></td>
<td><a href ng-click="removeItem($index)" class="glyphicon glyphicon-trash"></a></td>
<td ng-if=" form3.loyality || form3.value || form3.period " ><div id="c6"> <img ng-src="images/Assets/WIP.png" /></div></td>
</tr>
我的角度代码是
var validationApp = angular.module('validationApp', ['ngFlag']);
$scope.invoice = {
items: [{
loyality: [{name:'points'},{name:'credits'}],
value:0,
period: [{name:'activity1'},{name:'activity2'}]
}],
items1:[{currency: [{name:'point'},{name:'credit'}], value1:0 }]
};
$scope.submit = function() {
var data3=$scope.form3;
console.log(data3);
}
});