我想要做的是製作一個簡單的應用程序,用戶可以在平日裏編輯他的可用性。代碼工作正常..我從選擇框中獲取數據,但是當我試圖更新星期一數據的問題時,星期二數據也在用星期一**的相同值進行更新(正如您可以在上一個視圖中看到的那樣)**在angularJS中更新數組的數據
我的數據庫JSON
"doctorSchedule" : [
{
"_id" : null,
"working_day" : "Monday",
"working_from" : [
{
"_id" : null,
"hours" : "9",
"minutes" : "30"
}
],
"working_to" : [
{
"_id" : null,
"hours" : "6",
"minutes" : "30"
}
]
},
{
"_id" : null,
"working_day" : "Tue",
"working_from" : [
{
"_id" : null,
"hours" : "9",
"minutes" : "30"
}
],
"working_to" : [
{
"_id" : null,
"hours" : "6",
"minutes" : "30"
}
]
}
],
我的角碼。
$scope.data1 = $stateParams.viewUser;
$http({
url: "/getinfo",
method: "POST",
headers :{'Content-Type': 'application/json','Accept': 'application/json'},
data: dataParam
}).success(function(response) {
if(response.status_code == "worked") {
$scope.viewUser = response.clinicUserVo;
$scope.datasc = response.doctorSchedule;
}
});
我的HTML文件
<table class="table table-bordered" ng-repeat="docSchedule in data1.doctorSchedule">
<tr> <th scope="col"><input type="checkbox" ng-model="data1.working_day"></th>
<td>{{docSchedule.working_day}}</td>
<td>
<select id="user_time_zone" class="form-control form-group" ng-model="data1.working_from">
<option value="" >{{docSchedule.working_from[0].hours}}</option>
<option id="optionspec" value="01" >01</option>
<option id="optionspec" value="02" >02</option>
<option id="optionspec" value="03" >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>
<td>
<div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">
<select id="user_time_zone" class="form-control form-group" ng-model="data1.working_from">
<option value="" disabled="disabled">{{docSchedule.working_from[0].minutes}}</option>
<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>
<td><b>to</b></td>
<td>
<div class="col-md-12 col-sm-6 col-xs-12 form-group has-feedback">
<select id="user_time_zone" class="form-control form-group" ng-model="data1.working_to" name="user_time_zone">
<option value="" disabled="disabled">{{docSchedule.working_to[0].hours}}</option>
<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" class="form-control form-group" ng-model="data1.working_to" name="user_time_zone">
<option value="" disabled="disabled">{{docSchedule.working_to[0].minutes}}</option>
<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>
</tr>
<tr>
</tr>
<tr >
</table>
HTML視圖
看到在這個html頁面,當我試圖updatemonday數據和週二的數據也會自動改變我怎樣才能解決這個問題,通過角?
確定了..已經做到了,謝謝 – adasdasd
,但不知道我是否能夠通過與docSchedule.working_from – adasdasd
陣列你可能會審查你的格式化模型的方式。但至少你可以解決這個問題,「改變一個原因改變其他」 – daymannovaes