以下是HTML页面中视图的一部分,通过这个用户可以填充数据并将其发送到api
在表单中有三个参数将在单个数组中传递,一天。从时间到时间。如何在单个数组中传递这三个参数...在角度JS的jSON中,我的代码在这里不起作用是代码。 我现在还想知道如何在HTML / Angular视图中以这种格式发送数据?
我(我认为它会起作用)Angular Js代码
$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));
HTML代码
<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">
<option id="optionspec" value="" >00</option>
<option id="optionspec" value="01" >01</option>
<option id="optionspec" value="02" >02</option>
<option id="optionspec" value="o3" >03</option>
<option id="optionspec" value="04" >04</option>
<option id="optionspec" value="05" >05</option>
<option id="optionspec" value="06" >06</option>
<option id="optionspec" value="07" >07</option>
<option id="optionspec" value="08" >08</option>
<option id="optionspec" value="09" >09</option>
<option id="optionspec" value="10" >10</option>
<option id="optionspec" value="11" >11</option>
<option id="optionspec" value="12" >12</option>
<option id="optionspec" value="13" >13</option>
<option id="optionspec" value="14" >14</option>
<option id="optionspec" value="15" >15</option>
<option id="optionspec" value="16" >16</option>
<option id="optionspec" value="17" >17</option>
<option id="optionspec" value="18" >18</option>
<option id="optionspec" value="19" >19</option>
<option id="optionspec" value="20" >20</option>
<option id="optionspec" value="21" >21</option>
<option id="optionspec" value="22" >22</option>
<option id="optionspec" value="23" >23</option>
</select>
</div>
</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">
<option id="optionspec" value="" >00</option>
<option id="optionspec" value="05" >05</option>
<option id="optionspec" value="10" >10</option>
<option id="optionspec" value="15" >15</option>
<option id="optionspec" value="20" >20</option>
<option id="optionspec" value="25" >25</option>
<option id="optionspec" value="30" >30</option>
<option id="optionspec" value="35" >35</option>
<option id="optionspec" value="40" >40</option>
<option id="optionspec" value="45" >45</option>
<option id="optionspec" value="50" >50</option>
<option id="optionspec" value="55" >55</option>
</select>
</div>
</td>
<td><b>:</b></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">
<option id="optionspec" value="" >00</option>
<option id="optionspec" value="01" >01</option>
<option id="optionspec" value="02" >02</option>
<option id="optionspec" value="o3" >03</option>
<option id="optionspec" value="04" >04</option>
<option id="optionspec" value="05" >05</option>
<option id="optionspec" value="06" >06</option>
<option id="optionspec" value="07" >07</option>
<option id="optionspec" value="08" >08</option>
<option id="optionspec" value="09" >09</option>
<option id="optionspec" value="10" >10</option>
<option id="optionspec" value="11" >11</option>
<option id="optionspec" value="12" >12</option>
<option id="optionspec" value="13" >13</option>
<option id="optionspec" value="14" >14</option>
<option id="optionspec" value="15" >15</option>
<option id="optionspec" value="16" >16</option>
<option id="optionspec" value="17" >17</option>
<option id="optionspec" value="18" >18</option>
<option id="optionspec" value="19" >19</option>
<option id="optionspec" value="20" >20</option>
<option id="optionspec" value="21" >21</option>
<option id="optionspec" value="22" >22</option>
<option id="optionspec" value="23" >23</option>
</select>
</div>
</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">
<option id="optionspec" value="" >00</option>
<option id="optionspec" value="05" >05</option>
<option id="optionspec" value="10" >10</option>
<option id="optionspec" value="15" >15</option>
<option id="optionspec" value="20" >20</option>
<option id="optionspec" value="25" >25</option>
<option id="optionspec" value="30" >30</option>
<option id="optionspec" value="35" >35</option>
<option id="optionspec" value="40" >40</option>
<option id="optionspec" value="45" >45</option>
<option id="optionspec" value="50" >50</option>
<option id="optionspec" value="55" >55</option>
</select>
</div>
</td>
<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>
一小段java代码
public class Schedule {
private String Working_day;
private List<String> Working_from;
private List<String> working_to;
........ }
答案 0 :(得分:0)
替换
var dataParam = {"Schedule":[$scope.data1.schedule]} with
var dataParam = {"Schedule":$scope.schedule}