Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you want to use <code>injector</code>, <code>scope</code>, or any other build in angularjs provider as dependency of other service you need to prefix them with <code>$</code>, as angular by convention registers all build in providers with <code>$</code> prefix, so <code>scope</code> is registered as <code>$scope</code>, <code>injector</code> as <code>$injector</code> etc. </p> <p>When angular instantiates objects(using injector btw) it checks what dependencies object has (as it needs to inject them) and the way it's done is by checking variables names of constructor function of that object, so that's why it's so important to name variables correctly or you'll get error unknown provider ...</p> <p>When you retrieve injector as following:</p> <pre class="lang-js prettyprint-override"><code>var injector = angular.injector(['gaad', 'components']); </code></pre> <p>you don't use $ prefix, as it's normal variable and actually you can call it whatever you want ($injector included).</p> <p>When you want to have injector as dependency, you need to name it as following:</p> <pre class="lang-js prettyprint-override"><code>angular.module('app').factory('$exceptionHandler', function($injector) { ... }); </code></pre> <p>or (convention needed when you use minification of angularjs scripts):</p> <pre class="lang-js prettyprint-override"><code>angular.module('app').factory('$exceptionHandler', ['$injector', function(anyNameYouWant) { ... }]); </code></pre> <p>Similar for scope, when used in link function in directive:</p> <pre class="lang-js prettyprint-override"><code> link: function(scope, element, attr) { } </code></pre> <p>you don't have to call it $scope as nothing is injected here. It's only one of function parameters. You can call it whatever you want, but convention here is to use <code>scope</code> not <code>$scope</code> to differentiate cases when scope is injected and when is used as parameter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload