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

Note: Our aim while creating angular interview questions and answers, is to help you grow as an Angular Developer. The questions mentioned here have been asked by leading organizations during technical rounds of the interview process.

BY Best Interview Question ON 19 Jun 2020

Example

var $injector = angular.injector();
expect($injector.get('$injector')).toBe($injector);
expect($injector.invoke(function($injector) {
   return $injector;
})).toBe($injector);