0

I'm new in angular and my english is not very good, so i try to explain my problem the best i can.

I'm using the ui.bootstrap.modal in my project, and i need that the modal window i open can be controlled by another controller and not only ModalInstanceCtrl. I want to ModalInstanceCtrl manage the common actions in a modal window, (set title, close, etc..) and then another controller (SpecificController) manage specific actions.

So this is my modal template view now:

<h1>
   {{title}} 
   <a ng-click="closemodal()">x</a>
</h1>
<div ng-include  src="specificTemplate.html" ng-controller="SpecificController"></div> 

My idea is that specificTemplate.html and SpecificController can be set as a variables in the future and so having a system for manage modal windows with common actions, and other specific actions for each modal window. The include template works fine, but with the ng-controller label i get the following error:

Error: [$injector:unpr] Unknown provider: $modalInstanceProvider <- $modalInstance

I have SpeficController defined in my controllers section.

In other similar questions in StackOverflow, the problem were that ng-controller="ModalInstanceCtrl" was set in the template, but i want/need another controller for specific actions as a child one. How can fix this?

1 Answer 1

2

There are several ways you can manage this, but first of all - don't inject $modalInstance into SpecificController. If you need to close (or dismiss) a modal from within a scope created by the SpecificController you can do so by using the $close() and $dismiss() method available on the scope.

Having said the above your example is a bit too abstract to provide exact guidance so if you could provide a representative use-case using http://plnkr.co/ you would get more detailed answer.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, my problem was i was injected $modalInstance in SpecificController, (inherit from a Ctrl + C, Ctrl + V) X( now i don 't now if is posiible pass the SpecificController name as a var, (the template name work) but this is a different question
@pkozlowski-opensource plnkr.co/edit/OuBIcvbe08FqPc6wjyBq?p=preview I was trying to do it this way, but I'm getting same error in my app, when in the example provided error is missing in console window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.