Please see below code:
var fieldsControls = $filter('filter')(vm.FieldsControls, { FieldId: id });
for (var i = 0; i < fieldsControls.length; i++)
{
if (fieldsControls[i].ControlType == "DropDown") {
fieldsControls[i].Options = $filter('filter')(vm.Options, { type: fieldsControls[i].type });
}
}
return fieldsControls;
After return (or even after the for loop) I observed that the original array "vm.FieldsControls" is getting updated with new Options value. However, shouldn't this just change new array fieldControls only?