I have a service that uses ngDialog (that's the only purpose of the service - to show common dialogs: alerts, confirms, etc). ngDialog requires scope object to be passed as parameter to interpolate dialog's template. So I need to create a scope, assign it's properties and pass to ngDialog.open. The problem is I can't inject $rootScope (or $scope) into service, and scope.$new is the only way I could find to create an empty scope. When I inject $rootScope like this
myService.$inject = ['$rootScope', 'ngDialog'];
I get error: Unknown provider: $rootScope Provider <- $rootScope <- myService However, this works if I just use shortcut syntack for decalring dependencies:
function myService($rootScope, ngDialog) {
//$rootScope here is accessible
}
But this approach is not minification-safe. So the question is: how do I create new scope in a service?
UPDATE Here is the jsfiddle that shows the structure I had in the project. The error occurred when service was called from the directive, and now the problem is gone. jsfiddle
ngDialog requires scope object to be passed as parameter
- I don't think this is correct. Did you try not passing a scope? – pablochan