У меня возникают проблемы с исправлением вложенного объекта с помощью Restangular.
Объект, который я исправляю:
{
"unread_notification_count": 18,
"notification_settings": {
"mention": {
"email_notification": true,
"platform_notification": true,
"desktop_notification": true
},
"history_update": {
"email_notification": true,
"platform_notification": true,
"desktop_notification": true
},
"assign": {
"email_notification": true,
"platform_notification": true,
"desktop_notification": true
}
}
Я хочу исправить некоторые логические значения при переключении переключателя.
Когда я переключаю переключатель прямо сейчас, я запускаю эту функцию
$scope.patch = function(key, field, value) {
var updated = {
};
// Below this isnt working
updated['notification_settings'][key][field] = value;
Restangular.one('users/'+ Global.user.id).patch(updated).then(function (data) {
console.log('succes');
}, function(error) {
console.log(error);
});
}
Часть, с которой я не могу работать, - это то, что публиковать в обновленном объекте. Мне нужно обновить вложенное поле, но я не знаю как.
Например, я хочу установить уведомления_настройки -> упоминание (ключ) -> платформа_уведомление (поле) = true (значение)