Remove Duplicates value from Array using AngularJS

Remove Duplicates value from Array using AngularJS

how to prevent duplicate in array push in angularjs

First we need an al the array check which have duplicate values available or not so we will create an array other array with duplicate values and then this array process to remove all the duplicate values.Remove Duplicates value from Array using AngularJS -angularjs unique array



Remove Duplicates From Array in AngularJs Example

READ :  AngularJs Tables using ng repeat From JSON

var liveApp = angular.module(“liveApp”, []);
liveApp.controller(“liveCtrl”, function($scope) {
$scope.ageArrayval = [’25’,’44’,’98’,’44’,’50’,’71’,’50’];
$scope.dataresult = [];
$scope.deleteDuplicate = function() {
$scope.dataresult = $scope.ageArrayval.filter(function(item, pos) {
return $scope.ageArrayval.indexOf(item) == pos;

Array With Duplicate Values = {{ageArrayval}}
Click to simple Remove all the Duplicates Array .

Result : Final Array = {{dataresult}}



AngularJs Remove duplicate elements in ng-repeat Example

Just simple create a filter with remove duplicate id that gets the unique values


app.filter(‘datauniq’, function() {
return function(datacol, keyname) {
var dataout = [],
datakeys = [];

angular.forEach(datacol, function(item) {
var dk = item[keyname];
if(datakeys.indexOf(dk) === -1) {

return dataout;


Leave a Comment