Created
October 23, 2015 16:31
-
-
Save dboundz/d5f7d50237ad6e9579d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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