Moved some DOM manipulation code to the directive from the controller