Take the out the function in a service to avoid injection a controller in another controller.