I am creating objects when textbox having some values (using ng-blur and textbox.value!==undefined
) and then putting these objects in an array (all working fine here).
When I click on checkbox (checkbox model bind with textbox ng-required) I need to delete that particular object having that textbox value. I am using:
arr.splice(index,1);
to remove that particular object from array (by matching it's name like "monthly" or "quarterly" etc.), but it is creating null
at that particular position.
for e.g. [object,object,object]
[
{name:"monthly",
amount:1000 },
{name:"quarterly",
amount:1200 },
{name:"yearly",
amount:1300 }
]
after removing all element it shows []
and when I add another new object it displays [3:object]
and it's content as [null,null,null,object];
or
if I remove middle object say name:"quarterly",
it shows [object,object]
but after adding a new object it display array as [object,object,null,object]
with length of array as 4.
Why is there null
and how can I remove that from array. (don't want to iterate again to check null
).