Moved controller code into directive files.