Fixed the sidebar directive

Moved logic from controller into link.