Why does Angular UI Bootstrap use a provider to handle the logic in the modal and tooltip but not in the other components?

I've noticed that Angular UI Bootstrap uses a Provider to handle all the logic of the Modal and Tooltip component, but all the other components the logic is set inside a single controller that is shared by the directive and it's sub-directives.

So what is the benefit of using a Provider instead of a controller for only those two components?

Also why do the components accept options as data attributes which are read and parsed in the link function, instead of using the directives scope to accept the options?


  1. Providers vs. Controllers:

If you look at lines 349 and 350 of modal.js:

//merge and clean up options
modalOptions = angular.extend({}, $modalProvider.options, modalOptions);

You'll see that the options specified by the modal are merged with the options specified by the user, allowing the latter to override the former. This is presumably done so that at config time you may set the defaults in the provider and then they're set. Providers are used to configure your app at the beginning. I assume the other components don't have app-level-configuration and therefore don't need a provider (and can use factory or just a directive, etc.).

  1. Using scope: { /* ... */ } vs. not doing so in the directive

If you look at a random file I selected like buttons.js you'll see that options are parsed like so on line 22:


One reason to do that is so that you don't create an isolate scope, in general - creating one can mean you can't have another new-ed or isolate scope on the same element - so use them sparingly - and it also means that inner content cannot access scope variables on the outside (useful for ngTransclude). If I only need one value from the outside world and I can stick it on an attribute which is the name of my directive then I almost always just $observe or $eval or $interpolate it instead of creating an isolate scope.


 ? Force boolean result from promise function in angularjs
 ? Force boolean result from promise function in angularjs
 ? Force boolean result from promise function in angularjs
 ? Assign promise return value to an iterator (AngularJS)
 ? Using AngularJs Promise to Retrieve and Store an Entity
 ? How to get a value from returned result "Promise {$$state: Object}"
 ? Manipulate data from promise result
 ? Manipulate data from promise result
 ? Manipulate data from promise result
 ? using angularjs controller that consumes a service promise inside the view