Reputation: 360
I have a dialog I want to use in two different places, so I've built a template and a controller trackCtrl
for a modal to use. That controller is defined on the settingsApp
module which is not the one launching the modal, so I would like to do something like this:
var modalInstance = $modal.open({
templateUrl: 'templates/track.html',
controller: 'settingsApp.trackCtrl'
});
but it fails of course.
What is the best way to solve this problem?
thanks!
Upvotes: 2
Views: 2481
Reputation: 360
The problem was that the js file defining the controller was never run. (The controller should be referred to simply by its name.)
Upvotes: 0
Reputation: 8413
Just add a dependency to your other module and then just simply use that controller name.
angular('app', ['settingsApp']);
var modalInstance = $modal.open({
templateUrl: 'templates/track.html',
controller: 'trackCtrl'
});
Upvotes: 1