My objective is to create a basic application that allows users to adjust their availability on weekdays. The code is functioning correctly as it retrieves data from the select box. However, I encounter an issue when trying to update Monday's data and find that Tuesday's data is also being updated with the same values.
Here is my JSON database:
"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"
}
]
}
],
Below is my Angular code:
$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;
}
});
My HTML file includes the following components:
<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>
...
(more HTML code here)
...
</tr>
<tr>
</tr>
<tr >
</table>
I am experiencing issues where updates made to Monday also affect Tuesday's data in the HTML view. How can this be resolved using Angular?