diff --git a/Apollo/assets/js/controllers/studentViewCtrl.js b/Apollo/assets/js/controllers/studentViewCtrl.js index 19b0cdf8..b2447f5e 100755 --- a/Apollo/assets/js/controllers/studentViewCtrl.js +++ b/Apollo/assets/js/controllers/studentViewCtrl.js @@ -95,4 +95,22 @@ app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items","WordsS }]); +app.filter('unique', function() { + return function(collection, primaryKey, secondaryKey) { //optional secondary key + var output = [], + keys = []; + + angular.forEach(collection, function(item) { + var key; + secondaryKey === undefined ? key = item[primaryKey] : key = item[primaryKey][secondaryKey]; + + if(keys.indexOf(key) === -1) { + keys.push(key); + output.push(item); + } + }); + + return output; + }; +});