我有NG單擊事件是這樣的:避免在NG-重複採集添加複製的項目,在Angular.js
$scope.submitInfo = function myfunction() {
var itemToAdd = {
Id : generateUUID(),
Name: $scope.Name,
Email: $scope.Email,
Phone: $scope.Phone
};
$scope.Info.push(itemToAdd);
}
我的問題是,我要檢查是否相同ID
或Name
尚未存在在$scope.Info
集合中。
我是在angular.js purly FOUCS,我正在尋找最佳的解決方案爲這種情況
你必須通過收集迭代和比較每列添加數據。 – Claies
[Array .push()if possible does not exist?](http://stackoverflow.com/questions/1988349/array-push-if-does-not-exist) – Alex