I have the following:
$scope.jsonmarkers = [{
\"name\": \"Jeff\",
\"type\": \"Organisation + Training Entity\",
\"userID\": \"1\"
}, {
For removing duplicates you could use the unique filter from AngularUI (source code available here: AngularUI unique filter) and use it directly in the ng-options (or ng-repeat).
Look here for more: Unique & Stuff
Also there's a syntax error in json structure.
Working Code
Html
script
var app = angular.module("app", []);
app.controller("MainController", function ($scope) {
$scope.jsonmarkers = [{
"name": "Jeff",
"type": "Organisation + Training Entity",
"userID": "1"
}, {
"name": "Fred",
"type": "Organisation + Training Entity",
"userID": "2"
}];
});
app.filter('unique', function () {
return function (items, filterOn) {
if (filterOn === false) {
return items;
}
if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
var hashCheck = {}, newItems = [];
var extractValueToCompare = function (item) {
if (angular.isObject(item) && angular.isString(filterOn)) {
return item[filterOn];
} else {
return item;
}
};
angular.forEach(items, function (item) {
var valueToCheck, isDuplicate = false;
for (var i = 0; i < newItems.length; i++) {
if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
isDuplicate = true;
break;
}
}
if (!isDuplicate) {
newItems.push(item);
}
});
items = newItems;
}
return items;
};
});