I have an array of Drug Codes 'BARB', 'HALU', 'METH'
. I want to loop thru these codes and create a new object for each one.
var saveObj = {};
saveObj.SelectedList = [];
angular.forEach(self.DrugNamesSelected, function(value, key) {
//Load Objects into array
var newObj = {};
newObj = self.Selected;
newObj.FK_CLNT_PERSFK_PER = $routeParams.personId;
newObj.DRUG_TYP_CODE = value;
saveObj.SelectedList.push(newObj);
});
This is what I'm getting
saveObj.SelectedList[0].DRUG_TYP_CODE = 'METH' saveObj.SelectedList[1].DRUG_TYP_CODE = 'METH' saveObj.SelectedList[2].DRUG_TYP_CODE = 'METH'
This is what I need
saveObj.SelectedList[0].DRUG_TYP_CODE = 'BARB' saveObj.SelectedList[1].DRUG_TYP_CODE = 'HALU' saveObj.SelectedList[2].DRUG_TYP_CODE = 'METH'