I don't know much about angular.js
angular.js myself, but I can give some small tips about your code.
#IndentationIndentation
Code, in general, looks ugly without proper indentation.
I recommend that you indent the body of the second parameter passed into app.filter
.
#Why are you checking with 'undefined'?Why are you checking with 'undefined'?
On the line that goes:
if (typeof categories != 'undefined') {
Why are you comparing with 'undefined'
?
If you want to check is categories was defined, you could just do
if (categories) {