The AngularJS way of doing this would be to make this a filter but I'm fine leaving it a function unless we need it elsewhere.