Directive's controller function