I am working with a table where each cell in the rows contains form fields. The table also has two buttons: one button adds a new row to the table, and the other sends all the rows.
Below is the code snippet for adding new blank rows:
$scope.attributes = [];
$scope.addRow = function(){
var newRow = {attributeName: "", type: "", size: "", priority: "", mandatory: "", notes: ""};
$scope.attributes.push(newRow);
}
View :
<table class="table">
<tr>
<td>Attribute Name</td>
<td>Type</td>
<td>Size</td>
<td>Priority</td>
<td>Mandatory</td>
<td>Notes</td>
</tr>
<tr ng-repeat="attribute in attributes">
<td><input type="text" ng-model="attribute.attributeName" /> </td>
<td>
<select ng-options="option as option.value for option in options" ng-model="attribute.type"></select>
</td>
<td><input type="number" ng-model="attribute.size" /></td>
<td>
<select ng-options="option as option.value for option in options" ng-model="attribute.type"></select>
</td>
<td><input type="checkbox" ng-model="attribute.mandatory" ng-true-value="'YES'" ng-false-value="'NO'"></td>
<td><input type="text" ng-model="attribute.notes" /> </td>
</tr>
</table>
Angular Code for sending data to web Service :-
$scope.sendAttribute = function(){
$http.post("http://10.0.203.73/WS/ws.php/tipusactius/alta", $scope.attributes).success(function(data){
$scope.status = data;
})
}
Json Array Sending:-
[{"attributeName":"j",
"type":{"id_combo_value":"3","value":"Date"},
"size":11,"priority":"",
"mandatory":"YES",
"notes":"example"}]
Is everything correct or is the issue with the web service? Your feedback would be greatly appreciated as this is my first attempt using Angular. Thank you.