Hit a bit of brick wall here so hoping for some guidance.
I'm building up a scope variable called 'display' which is built off 2 http calls which I haven't included to keep it simple. Basically all i'm doing is adding product types to the each category object.
$scope.display = {};
portal.fetchCategories().then(function(data) {
$scope.categories = data.categories;
return portal.fetchProductTypes();
})
.then(function(data) {
$scope.productTypes = data.product_types;
angular.forEach($scope.categories, function(value) {
$scope.display[value.id] = {
title: value.title,
start: value.start,
end: value.end,
product_types: $scope.productTypes
};
});
})
This all works fine.
The trouble I'm having is when I target a product type inside a category like this and attempt to update the title:
$scope.display[2].product_types[0]['title'] = "Updated Title";
It is actually updating the product type title in all the categories rather than just specified category. I suspect it's just updating $scope.productTypes.
Can anyone shed any light on what I'm doing wrong?