Skip to content

Instantly share code, notes, and snippets.

@dboundz
Created October 23, 2015 16:31
Show Gist options
  • Save dboundz/d5f7d50237ad6e9579d4 to your computer and use it in GitHub Desktop.
Save dboundz/d5f7d50237ad6e9579d4 to your computer and use it in GitHub Desktop.
baseApp.filter("emptyToEnd", function () {
return function (array, key) {
var keys = key.split(".");
if (!angular.isArray(array)) return;
var present = array.filter(function (item) {
if(keys.length > 1) {
return item[keys[0]][keys[1]];
} else {
return item[keys[0]];
}
});
var empty = array.filter(function (item) {
if(keys.length > 1) {
return !item[keys[0]][keys[1]];
} else {
return !item[keys[0]];
}
});
return present.concat(empty);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment