Skip to content

Instantly share code, notes, and snippets.

@toboqus
Created December 2, 2015 13:23
Show Gist options
  • Save toboqus/bd382461d8e724a8389d to your computer and use it in GitHub Desktop.
Save toboqus/bd382461d8e724a8389d to your computer and use it in GitHub Desktop.
Pushing an object onto another object if the element names match
/**
* @name pushToTemplate
* @param template
* @param object
* @returns {object}
* @description will push the object onto the template
*/
var pushToTemplate = function pushToTemplate(template, object){
var result = angular.copy(template);
//push stored values onto copied template
for (var prop in result) {
if (prop in object) {
result[prop] = object[prop];
}
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment