Welcome to the HTML page view where users can input data and send it to an API.
https://i.sstatic.net/uJTYc.png
Within the form, three parameters need to be passed in a single array: day, fromtime, and to-time. How can these three parameters be passed in a single array in JSON using AngularJS? My code isn't functioning properly, here is what I have so far. I'd also like to know how to format and send the data in HTML/Angular view side?
This is my attempt at AngularJS code:
$scope.schedule = [];
$scope.schedule[0] = $scope.data1.day;
$scope.schedule[1] = $scope.data1.from_time;
$scope.schedule[2] = $scope.data1.to_time;
var dataParam = {
"Schedule": [$scope.data1.schedule]
}
console.log(angular.toJson(dataParam));
Here is the corresponding HTML code:
<tr>
<th scope="col"><input type="checkbox" name="checkbox1" ng-model="data.checkbox1"></th>
<td ng-model="data1.day">Sunday</td>
<td>
<div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">
<select id="user_time_zone" ng-disabled="!data.checkbox1" class="form-control form-group" value="Schedule" name="user_time_zone">
... (additional select options)
</select>
</div>
</td>
... (repeated select options for different values)
<td>
<div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">
<input type="button" class="btn btn-primary" value="Add Break" id="btn" ng-disabled="!data.checkbox1">
</td>
</tr>
Finally, a java code snippet showcasing the Schedule class:
public class Schedule {
private String Working_day;
private List<String> Working_from;
private List<String> working_to;
........ }