I have two arrays like this:
var obj1 = [{'target_object_id': 1, 'extra': 'ok'}, {'target_object_id': 2, 'extra': 'ok'}]
var obj2 = [{'id': 4}, {'id': 2}]
What I want to do is loop through obj1 and obj2 and
if obj1.target_object_id == obj2.id // Append obj2['extra']=obj.extra
How to do this in angular?
This would be with angular :
angular.forEach(obj1, function(item1) {
angular.forEach(obj2, function(item2) {
if(item1.target_object_id===item2.id) {
item2.extra = item1.extra; // change it as you wish
// some code
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With