I have a AngularJS controller set up as shown below:
schedule.controller('schedule', ['$scope', '$http', function($scope, $http){
$http.get('/zt-api/business/admin/' + window.location.pathname.split('/')[2]).success(function(data){
$scope.admin_times = data;
$scope.admin_times_unix = data;
$scope.weekDays = {'Saturday': "شنبه", 'Sunday': "یکشنبه", 'Monday': "دوشنبه", 'Tuesday': "سه شنبه",
'Wednesday': "چهارشنبه", 'Thursday': "پنجشنبه", 'Friday': "جمعه"};
angular.forEach($scope.admin_times, function (value, key) {
angular.forEach(value, function (value2, key2) {
angular.forEach(value2, function (value3, key3) {
angular.forEach(value3, function (value4, key4) {
angular.forEach(value4, function (value5, key5) {
var info = $scope.admin_times[key]["week_"+ key][key3].times[key5];
if (!isNaN(info)){
var myObj = $.parseJSON('{"date_created":"'+ $scope.admin_times[key]["week_"+ key][key3].times[key5] +'"}'),
myDate = new Date(1000*myObj.date_created);
$scope.admin_times[key]["week_"+ key][key3].times[key5] = myDate.toLocaleString().split(", ")[1]
}
});
});
});
});
});
});
}]);
I updated $scope.admin_times
, but strangely, $scope.admin_times_unix
is also getting updated.
Why is this happening? Any suggestions on how to fix it?