"Cannot read property 'id' of undefined" when parsing an array declared in a factory
First, as said in the comments, you need to make sure the message
object passed is really the one you're looking for.
Then, if you just want to splice you can do:
fooMessages.TopBarDismiss = function (message) {
var index;
for (var i = 0; i < fooMessages.length; i++) {
if(fooMessages[i].id == message.id) {
index = i;
break;
}
}
if (index) {
fooMessages.splice(index,1);
}
}