gpt4 book ai didi

javascript - 通过 Angular JS 发布多个数组数据

转载 作者:行者123 更新时间:2023-12-01 17:42:28 24 4
gpt4 key购买 nike

这是 HTML 页面中的 View 部分,用户可以通过它填写数据并将其发送到 api

enter image description here

在表单中有三个参数将传入一个数组,天。时不时地。如何在单个数组中传递这三个参数...在 Angular JS 的 jSON 中,我的代码在这里不起作用是代码。 我现在还想知道如何在 HTML/Angular view 端以这种格式发送数据?

我的(我认为它会工作)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;

........ }

最佳答案

替换

var dataParam =  {"Schedule":[$scope.data1.schedule]} with
var dataParam = {"Schedule":$scope.schedule}

关于javascript - 通过 Angular JS 发布多个数组数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39341661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com