I have two separate objects which is shown below
Object1 = [{value:'A/B'},{value:'A/B/C'},{value:'A/F'},{value:'A/'}];
Object2 =[{option:'A/'},{option:'A/B'}];
Now i need to modify the Object2 by adding a new attribute so that the Object2 must look like this
Object2 = [{option:'A/',
directories:[{value:'A/'},{value:'A/B'},{value:'A/B/C'},{value:'A/F'}]},
{option:'A/B',
directories:[{value:'A/B'},{value:'A/B/C'},{value:'A/F'},{value:'A/'}]}];
The changes what i need is
In directories attribute the first value should be the option value
Other values should be the remaining values that should come from Object1
I have tried the following code
angular.forEach(Object2,function(value,key){
angular.forEach(Object1,function(value,key){
//I need the code here
});
});