我正在尝试遍历集合中的项目列表并比较每个项目,如果要添加到集合中的项目的电子邮件地址已经存在,但出现运行时错误“JavaScript 运行时错误:预期功能”。请任何人帮助我下面的代码缺少什么?
视图模型
self.AddReceiver = function () {
var newReceiverData = ko.toJS(self.newReceiver);
if (ReceiverValidate()) {
ko.utils.arrayForEach(self.receivers(), function (item) {
if (item.EmailAddress() == newReceiverData.receiveremailaddress) {
alert("Email already exist on the list");
return false;
}
});
self.receivers.push({
EmailAddress: newReceiverData.receiveremailaddress,
FirstName: newReceiverData.receiverfirstname,
LastName: newReceiverData.receiverlastname
});
ClearReceiverInput();
}
};
截图错误