Created
December 2, 2015 13:23
-
-
Save toboqus/bd382461d8e724a8389d to your computer and use it in GitHub Desktop.
Pushing an object onto another object if the element names match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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