AngularJs Note: $injector Vs $inject Vs Injector()

Following are the key differences:


#injector: Used to invoke or get dependencies into variables

   //gets the implementation of service called 'A' 

   //returns the value of implementation of service 'A'

#$inject: Used to inject dependencies into a function arguments

   var test = function('A', 'B'){} 
   test.$inject = ['A', 'B']

#injector(): Used on document object which is mainly used to bring non-angular environment code into angular environment.

   var $div = $('<div ng-controller="MyCtrl">{{content.label}}</div>'); 
   angular.element(document).injector().invoke(function($compile) { 
     var scope = angular.element($div).scope(); 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s