title: Angularjs: get service name from within service
body: <p>How can I get the name of a <code>service</code> (or <code>factory</code>, <code>provider</code>, <code>controller</code>, <code>directive</code>...) from WITHIN the object?  Eg</p>
  
  <pre><code>angular.module('app', []).controller('myCtrl', function() {
    // how do I get the name 'myCtrl' here?
  })
  </code></pre>
  
  <p>The obvious way is hard coding, but I want to avoid that</p>
  
  <pre><code>.service('myService', function() {
    this.name = 'myService';
  });
  </code></pre>
  
  <p>I guess this is a way, but I'm hoping to avoid it as I don't want to have to declare globals in my app</p>
  
  <pre><code>var myCtrlName = 'myCtrl';
  angular.module('app', []).controller(myCtrlName, function() {
    console.log(myCtrlName);
  });
  </code></pre>