Bhuvanesh Mohankumar
what is injector in Angular Js?
By Bhuvanesh Mohankumar in Angular on May 05 2016
  • tejaswini jadhav
    Dec, 2018 20

    a

    • 0
  • sushil kumar
    Aug, 2017 30

    AngularJS injector is key to making dependency injection work in Angular. The angular.injector() function is used to create injector object for dependency injection and services retrieving. Using injector, you can register factory, service and directive modules methods.Syntaxangular.injector(modules, [strictDi]);

    • 0
  • sreedhar puligundla
    Apr, 2017 10

    function MyCtrl($scope, $injector) {$scope.doSomething = function(someService) {var service = $injector.get(someService) // someService contains the name of a serviceservice.value += 10 }

    • 0
  • sreedhar puligundla
    Apr, 2017 10

    There is one injector per Angular application. Normally you don't need to interact with it directly. The injector is key to making dependency injection work in Angular.Module methods such as factory, service, directive, etc. register these items with the injector. When you inject something (e.g., a service into a controller), the injector will lookup and then instantiate the service (if it wasn't instantiated already -- if it was, it will return the already-instantiated object).If for some reason you really needed to dynamically inject a service into, say, a controller, see http://stackoverflow.com/a/14418384/215945 for an example of how to do that. See also http://stackoverflow.com/a/14743553/215945

    • 0
  • Bhuvanesh Mohankumar
    May, 2016 5

    An injector is a service locator. It is used to retrieve object instances as defined by provider, instantiate types, invoke methods and load modules.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS