Consider the following nested object that loops 10 times to product a object with schedules for 10 weeks, for every monday at the given times:
(考虑以下嵌套对象,该嵌套对象循环10次,以在给定时间的每个星期一循环生成10周时间表的对象:)
$rootScope.bookings_times_list = [];
for (i = 0; i < 10; i++) {
$rootScope.bookings_times_list.push({
week: i,
schedule: [{
booking_day: "Monday",
booking_times: [{
"booking_start_time": "00:15",
"booking_end_time": "01:00",
"booking_selected": "",
"booking_selected_date": "",
"booking_time": "30 Nov 2019 07:35hrs"
}]
}]
});
}
The problem is that changing the booking_selected
value to 1
as shown below changes the values for all booking_selected
keys for every week to 1
:
(问题在于,如下所示将booking_selected
值更改为1
,将每周所有booking_selected
键的值更改为1
:)
$rootScope.bookings_times_list[0].schedule[0].booking_times[0].booking_selected = 1;
Why would this happen when the key for $rootScope.bookings_times_list[0]
is clearly set to 0
?
(当$rootScope.bookings_times_list[0]
的密钥明确设置为0
时,为什么会发生这种情况?)
ask by Dakarai Mshoperi translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…