title: AngularJS override service injection in some cases
body: <p>I have an angular service (let's call it $superService), and I use it in lots of my directives, controllers etc. But I also have one specific directive that I would like to have the following behaviour: If I place any other directive inside that specific one, and that directives use $superService in their own controllers, I want another instance of $superService to be injected there. Let me give you an example of how I do it now:</p>
  
  <pre><code>function SuperService(){
      this.action = function(){
          // some action
      }
  }
  var module = angular.module('module');
  module.service('$superService', SuperService);
  module.directive('oneDirective', function(){
      return {
           scope: {
               customSuperService: '='
           },
           // transulde, replace, restrict and other if needed
           controller: ['$scope', '$superService', function($scope, $superService){
               if($scope.attrs.customSuperService)
                    $superService = $scope.customSuperService;
  
               // code utilizing $superService
           }
           link: function($scope, $element, $attrs){
                $scope.attrs = $attrs;
           }
      };
  }).directive('specificDirective', [function(){
      return {
           transclude: true,
           replace: true,
           scope: true,
           template: '&lt;div ng-transclude&gt;&lt;/div&gt;',
           compile: function(){
               pre: function($scope, $element, $attrs, $transclude){
                    $scope.customSuperService = new SuperService();
               }
           }
      };
  }]);
  </code></pre>
  
  <p>So normally I would use oneDirective as follows:</p>
  
  <blockquote>
    <p><code>&lt;div one-directive&gt;&lt;/div&gt;</code></p>
  </blockquote>
  
  <p>But when i use it in specificDirective I have to write markup as this:</p>
  
  <pre><code>     &lt;div specific-directive&gt;
           &lt;div one-directive custom-super-service="customSuperService"&gt;&lt;/div&gt;
       &lt;/div&gt;
  </code></pre>
  
  <p>Is there a better way to do this? Perhaps using custom service providers? I would want a solution in which i would write markup like this:</p>
  
  <blockquote>
  <pre><code>&lt;div specific-directive&gt;
      &lt;div one-directive&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  </blockquote>
  
  <p>Without explicitly passing the custom instance to the directive.</p>