Moved controller method to make directive more readable.