Remove controller function as it was not used as controller function and move the functions under link function. Remove setTimeout and use  for better testability. Remove ng-keyup and use element.on