I have an ng-repeat with duplicates that need to be removed. According to the doc, the unique function is a part of Angular UI, which does not appear to be included in Umbraco. Is there a way to add it Angular UI? How do I remove the duplicates?
Maybe you can add a custom filter to make it works:
// here we define our unique filter
testApp.filter("unique", function() {
// we will return a function which will take in a collection
// and a keyname
return function(collection, keyname) {
// we define our output and keys array;
var output = [],
keys = [];
// we utilize angular's foreach function
// this takes in our original collection and an iterator function
angular.forEach(collection, function(item) {
// we check to see whether our object exists
var key = item[keyname];
// if it's not already part of our keys array
if (keys.indexOf(key) === -1) {
// add it to our keys array
keys.push(key);
// push this item to our final output array
output.push(item);
}
});
// return our array which should be devoid of
// any duplicates
return output;
};
});
I am trying to modify the Content Picker in Umbraco's BackOffice and my knowledge of Angular is Basic. How do I get that to work with / in the controller Umbraco.Overlays.ItemPickerOverlay?
How to remove duplates in ng-repeat
I have an ng-repeat with duplicates that need to be removed. According to the doc, the unique function is a part of Angular UI, which does not appear to be included in Umbraco. Is there a way to add it Angular UI? How do I remove the duplicates?
Hi Graham
Maybe you can add a custom filter to make it works:
Thank you Alex.
I am trying to modify the Content Picker in Umbraco's BackOffice and my knowledge of Angular is Basic. How do I get that to work with / in the controller Umbraco.Overlays.ItemPickerOverlay?
see: https://our.umbraco.com/forum/using-umbraco-and-getting-started/99913-how-to-create-custom-itempickerhtml
is working on a reply...