$scope.displayyears = []; $scope.Joinyear = function(display) { $scope.yeardisplay = display; $scope.yeardisp = $scope.displayyears.push($scope.yeardisplay); $scope.displayyeaRSS = uniq($scope.yeardisp) }
它会抛出错误,如“uniq is undefined”..我们如何检查唯一性?
在添加之前,请尝试检查yeardisplay是否已经在阵列中
原文链接:https://www.f2er.com/angularjs/142704.html$scope.displayyears = []; $scope.Joinyear=function(display){ $scope.yeardisplay=display; if ($scope.displayyears.indexOf(display) == -1) { $scope.displayyears.push(display); } }