Overwrite properties in angular forEach
angularjs
Solution
You should have a look at the solution of Josh David Miller which uses the extend method of angular (documentation).
var defaults = {name:'John',age:17,weight:55};
var overrides = {name:'Jack',age:28,color:'brown'};
var props = angular.extend(defaults, overrides);
// result
props: {
name:'Jack',
age:28,
weight:55,
color:'brown'
}
The values are copied in the defaults variable. There is no need of using the return value (var props =).
Problem
I imagine this is an easy thing to do, but I wasnt able to find the information I was looking for through google. I have `popupProperties` which is just default stuff. I then call to the service which returns specific overrides depending on the popup. How can I iterate through all of the service's overrides and apply them to the `popupProperties`? ``` var popupProperties = getDefaultPopupProperties(); var popupOverrides= popupService.getPopupOverrides(currPopupId); angular.forEach(popupOverrides, function(popupProperty, propertyName){ //replace defaults with popupData's properties }); ```