Refactor modal into a directive.