这里我使用Array来避免重复数据,我写了这段代码if (EmployeeList.indexOf(EmpDetails) == -1)
这里我得错误,因为Array的EmployeeList不是defind
$scope.EmployeeList = [];
$scope.SaveDb = function (Isvalid) {
var EmpDetails = [{
'EmpName': $scope.EmpName,
'Email': $scope.Email
}]
$scope.EmployeeList.push(EmpDetails);
console.log($scope.EmployeeList);
}
}
})
答案 0 :(得分:0)
你正在将数组推入数组尝试推送
$scope.SaveDb = function (Isvalid) {
var EmpDetails = {
'EmpName': $scope.EmpName,
'Email': $scope.Email
};
$scope.EmployeeList .push(EmpDetails);
}
答案 1 :(得分:0)
你正在数组中推送数组,并且在ng-repeat
中你试图获取数组上对象的属性。那就是问题所在。尝试在数组中推送对象,这应该可以解决问题
$scope.EmployeeList = [];
$scope.SaveDb = function (Isvalid) {
var EmpDetails = {
'EmpName': $scope.EmpName,
'Email': $scope.Email
}
$scope.EmployeeList .push(EmpDetails);
}
})