Questions tagged [angularjs-injector]

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

From Angularjs documentation:

$injector

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

angular.injector

Creates an injector object that can be used for retrieving services as well as for dependency injection

144 questions
64
votes
9 answers

Module is not available, misspelled or forgot to load (but I didn't)

I am fairly new to angular and using it with JSON api files. TO test, I am trying to use the free github api (my names for functions are for a different json api that i will be working with later). I just wanted to see if my functions were working…
user3606237
13
votes
2 answers

Are ES6 arrow functions incompatible with Angular?

Here's a normal ES5 function in my Angular code which works: app.run(function($templateCache){ $templateCache.put('/some','thing') }); I wanted to convert it to ES6 arrow function app.run($templateCache => $templateCache.put('/some','thing')); but…
11
votes
2 answers

Unknown provider: $rootElementProvider when using $injector to get $location service before angular.bootstrap

Hello I am trying to manually bootstrap an angular app, but there is some business that needs to be taken care of first.This article mentions the technique I am interested in. when I inject this: var $injector = angular.injector(["ng"]); var…
Jeremythuff
  • 1,518
  • 2
  • 13
  • 35
9
votes
2 answers

Error No provider for NgZone

I have an application that uses Angular Google Maps to show a location. At the beginning I was able to show the map, but since a while (probably I have modified something) I am getting the following error: ERROR Error: Uncaught (in promise): Error:…
Ivett
  • 111
  • 1
  • 3
9
votes
5 answers

Inject module dependency (like plugin) only if needed AngularJS

I have 2 pages (I don't use the angular's routing - This constraint). In one of them I want to use the directive ui-grid like in this demo: var app = angular.module('myApp', ['ui.grid']); app.controller('mainCtrl', function($scope) { …
Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
7
votes
3 answers

AngularJS dependency injection swap implementation

I'm still learning AngularJS, and have a question regarding their flavor of dependency injection. For example purposes, say I have a DataProcessor service which has a processData method that takes in a uri parameter and it needs to read that data…
chinabuffet
  • 5,278
  • 9
  • 40
  • 64
6
votes
3 answers

AngularJS two different $injectors

Today I found, that $injector injected to config or provider is different from $injector injected to service, factory or controller. And get() function from this $injectors works differently. $injector from config or provider, can't get() any…
5
votes
1 answer

Why does Angular let you inject the $provide service into config blocks?

As per Angular documentation, we can only inject Providers (not instances) in config blocks. https://docs.angularjs.org/guide/module#module-loading-dependencies But contrary to this Angular lets you inject $provide or $inject in spite of them being…
5
votes
1 answer

AngularJS injector issue

I'm trying to call a WebAPI from AngularJS. It is a simple GET request, and I have enabled CORS on the server. I am getting the $injector:unpr Unknown Provider error. I have an angular module called raterModule.js: var raterModule =…
5
votes
1 answer

Loading Module After Angular Bootstrap

I am trying to load and inject a module after app bootstrap. For example let's say my initial module is: angular.module('mainApp', []); Later on I realize the user needs all of the routes available via secondaryApp to open up to them. So now I…
4
votes
1 answer

Inject a module into karma test in Angular 1.5

I am trying to upgrade my Angular app from 1.3.x to 1.5.1. I have a suite of tests that all ran fine with Karma + PhantomJS when I was at version 1.3.x of Angular, however once I upgraded all of my tests are failing. It appears that the way I was…
Mike Caputo
  • 1,156
  • 17
  • 33
4
votes
1 answer

AngularJS service injection based on feature detection

In my Angular app, I need to create a persistence service interface that calls a concrete implementation based on the persistence mechanisms available in my browser. I am thinking of implementing this using a generic storageService that calls a…
Naresh
  • 23,937
  • 33
  • 132
  • 204
4
votes
1 answer

Creating a generic angularjs listController

Angular ui-router allows me to resolve different injections that I can use in my controllers. I created a simple generic ListController, and in the ui-router I am injecting an object that contains the CRUD functions specific for that particular…
XelharK
  • 598
  • 8
  • 21
4
votes
5 answers

Angular JS Error: [$injector:modulerr]

Edit: Now that I have actually worked using angularjs, I do not recommend anyone do what I was trying to accomplish. This is my first Angularjs application so I am a nooby, and still trying to figure things out. But I am receiving an error in my…
ryandawkins
  • 1,537
  • 5
  • 25
  • 38
3
votes
2 answers

Angular use multiple instances of service of parent component to child

I've seen this thread: Using multiple instances of the same service. Is it possible to use same multiple instance of a service from parent to children? For example, I have an ElementService in ParentComponent and have 2 instances of that service {…
Emmanuel Sayson
  • 279
  • 3
  • 14
1
2 3
9 10