Use the same controller for modal and non-modal template in Angular UI Bootstrap


I am using “Angular UI-Bootstrap” modal directive ( to open my template in modal window. And my controller that handles modal template which takes $modalInstance as one of its dependency. But now the issue is that for desktop and tablet view I want my template to open as modal window. While for mobile view I don’t want modal window but the same template need to open as separate page. Here I’m trying to use same controller and same html template for the both mobile view as well as desktop view.

But in mobile view the controller wasn’t created via $ method and so Angular throws an error something like: Unknown provider: $modalInstanceProvider <- $modalInstance.
Continue reading