A fork from angular-bootstrap-jbruni. Added some more logic.