I have an array of objects
var Country = [];
This is something like
{
"Name" : "IND"
"Capital" : "Delhi"
id : someID1
},
{
"Name" : "USA"
"Capital" : "WS"
id : someID2
},
{
"Name" : "UK"
"Capital" : "London"
id : someID3
}
Now I want to remove an item from a specific condition. But this is a mistake for more than two entries.
My mistake:
Unable to read the 'id' property from undefined
My code
remove : function(me, record, index){
var CountryRec = this.Country;
var CountryLen = this.Country.length;
for(var i=0; i<CountryLen; i++){
if(record.data.id == this.CountryRec[i].id){
checkRec.splice(i,1);
}
}
}
This is a mistake for more than two entries. Please suggest me what I am doing wrong.
source
share