For the true behavior of a private decorator, @ pkozlowski.opensource has the correct answer No. However, you could simulate this behavior.
One way to get closer to the desired behavior is to create a module that is unknown to all other parts of the application, which contains all the services / controllers / directives that should remain closed. Then the module that you will expose to other developers can use the "private" module as a dependency.
Example:
Mymodule.js
angular.module("my.module.private_members", []) .provider("PrivateService", function() { ... }); angular.module("my.module", ["my.module.private_members"]) .provider("PublicService", function($PrivateServiceProvider) { ... });
Main.js
angular.module("app", ["my.module"]) // The following line will work. .config(function($PublicServiceProvider) { ... }); // The following line causes an error .config(function($PrivateServiceProvider) { ... });
Of course, this will not work if the developer of the "app" module finds out that he then includes the module "my.module.private_members" as a direct dependency of the "app" module.
This example should apply to controllers.
source share