title: Inject dependency from parent controller
body: <p>We are using <code>$routeProvider</code> to inject some dependencies to the routing configuration. Something like this:</p>
  
  <pre><code>.when("/some/url", { 
      templateUrl: "/some/html",
      controller: "someController",
      controllerAs: "vm", 
      resolve: {
          __variable: ["someServiceDependency", function (someServiceDependency) {
              return someServiceDependency.someCall();
          }]
      }
  })
  </code></pre>
  
  <p>that way we inject __variable to our controller:</p>
  
  <pre><code>angular
      .module("someModule")
      .controller("someController", someController);
  
  someController.$inject = [
      "$scope",
      ...
      "__variable"];
  
  function someController(
      $scope,
      ...
      __variable) {
      ... here we do something with __variable
  }
  </code></pre>
  
  <p>The problem we have now is that this <code>someController</code> is rendered via routing, but also is used as a nested controller from other controllers</p>
  
  <pre><code>&lt;div&gt;
    ....some html rendered via ng-route.....
    &lt;div ng-controller="someController"&gt;
      ... specific data from someController
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>thus, when rendering the nested controller, angular cannot find the __variableProvider, as it does not exist.</p>
  
  <p>One option is to declare all this dependencies as providers, instead of setting them in the <code>resolve</code> section, but finally that approach will create tens of providers, and we prefer to keep the control in one part.</p>
  
  <p>Is it possible to "inject" via ng-init, or inject if the provider exists, or fill with empty if not exists? that way we can do something like:</p>
  
  <pre><code>&lt;div&gt;
    ....some html rendered via ng-route.....
    &lt;div ng-controller="someController" ng-init="initVariable(__variable)"&gt;
      ... specific data from someController
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>