Angular directive

Moved stuff out of controller html and into directive.