It would be better to implement this as an angularjs filter