Convert directive to controller