4
Reply

What is use of @Injector in Angular

Manav Pandya

Manav Pandya

6y
1.7k
1
Reply

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

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

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

    A service can be dynamically injected (by name) into a controller using the $injector. Being able to inject services via controller arguments is just a convenience that Angular provides. Under the hood, the $injector is used by Angular to retrieve object instances. But we can use the $injector ourselves also.function MyCtrl($scope, $injector) {$scope.doSomething = function(someService) {var service = $injector.get(someService) // someService contains the name of a serviceservice.value += 10 }https://stackoverflow.com/questions/14415845/angularjs-dynamically-inject-scope-or-controller/14418384#14418384https://docs.angularjs.org/api/auto/service/$injector