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

learn more… | top users | synonyms

5
votes
4answers
147 views
+50

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']); ...
1
vote
0answers
18 views

AngularJS: Dynamic injection of modules after loading another js file

My broader problem statement is to reduce the JS file size used in the main web page. I minified using grunt uglify to reduce it from 455KB to 140KB. As a second step, I am removing unnecessary ...
0
votes
2answers
31 views

Refer to service in run immediately after definition?

I would like to attach a string from a service to every request. Attempt: 'use strict'; angular.module('main') .service('Foo', function () { self.bar = 'haz'; }) .run(function ...
0
votes
2answers
123 views

AngularJS 1.4.8 $injector:Modulerr Module Error

I am relatively new to AngularJS and am getting an "Uncaught Error: [$injector:modulerr]". In addition, I am getting several syntax errors on the first line of various js files. error screenshot ...
0
votes
0answers
10 views

Angular - Ionic $injector is empty on wp8 platform

I have a simple app' maked with angular in ionic (just "ionic start project"). And in my function 'Run' i've : .run(function($injector) { console.log('->'); console.log($injector); ...
0
votes
1answer
37 views

Karma: how to unit test the filter with dependencies?

I'm trying to unit test filter which has dependency on another service. I've read many answers regarding this problem but nothing solved mine. I use karma/Jasmine the conf as follow // Karma ...
0
votes
1answer
32 views

Injecting service variable to Directives

So I am having a bit of trouble. I have looked through all of the previous solutions from Injecting service to Directive, but I really have no idea what I'm doing wrong. I have an authServices shown ...
1
vote
1answer
48 views

Angular.js circular dependency error in ui-router wrapper

I'm following John Papa's angular style guide (https://github.com/johnpapa/angular-styleguide#routing) and using a custom wrapper around the angular ui-router provided in this guide. However, the ...
0
votes
0answers
30 views

Conceptual: Setter Dependency Injection for Angular 1.*

preface - this is more a conceptual discussion rather than a "how-to". If there is a simple way to implement, then I would certainly be thankful for tips on how but I really want to gain insight on ...
1
vote
2answers
35 views

Dynamically inject service to a controller

Instead of specifying all the services in a controller like: mainApp.controller('MultiController', ['$scope', '$attrs', '$branchesService', '$repositoriesService', function ($scope, $attrs, ...
0
votes
1answer
50 views

$injector:unpr Unknown provider: eProvider <- e <- debounce

I have the following controller in my app, which works fine on my machine. When I push to production and the code is minified, I get the following error: Error: [$injector:unpr] Unknown provider: ...
8
votes
2answers
165 views

Are ES6 fat 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 fat arrow function ...
0
votes
0answers
37 views

Angular JS script files loading sequence erroring?

I have a file "A.js" in which I have a initialised a module as given below angular.module("x", []); I have another file "B.js" in which also I have initialised a module as give below, in this case ...
1
vote
1answer
37 views

Angularjs $injection::unpr error

I am trying to inject my service, but I keep getting unpr error. I followed the angularjs doc, but it didn't seem to solve it. I am at a loss for why this error keeps coming up. My Service ...
1
vote
1answer
31 views

Call $provide outside config. Angular

I know that is not possible to call $provide outside the config block. Is there any trick to inject $provide to a service calling it at $provide.decorator ? angular.module('app', []) ...
0
votes
1answer
44 views

Error in Dependency Injection when I try minify angular app

I have done a web application based in ASP MVC and angularJS, and everything works fine. Now, I want deploy it. In my bundleConfig I have put BundleTable.EnableOptimizations = true; to minified my ...
0
votes
1answer
60 views

Making promises in modules

I try to make facebook registration module in my app. Facebook API is faster than my Angular controller, so promise should be used here. The problem is that $q seems to be an empty object and defer ...
2
votes
1answer
98 views

Angular.js Uncaught Error: [$injector:modulerr]

<html> <head> <title>Schedule Task</title> <meta charset="utf-8" /> <script ...
0
votes
3answers
45 views

Using $injector vs. direct DI in angularjs?

I am not seeing the difference (or pros/cons) to directly injecting my dependencies vs. using $injector in angularjs. Why would I do one or the other? Here is a sample of the two. angular ...
0
votes
0answers
85 views

Strange Angular Error 'unknown provider'

To whom it may concern, My app suddenly stopped rendering because of this error: Uncaught Error: [$injector:unpr] Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- ...
0
votes
1answer
54 views

Angular Delayed Compilation Skipping ng-bind

Background You can invoke the $compile after your angular application has been bootstrapped by using the angular.injector method. angular.injector(['ng', 'late']).invoke(function($rootScope, ...
0
votes
0answers
26 views

keep an $injector reference in a controller

Based on all my readings regarding on how to implement a killer controller, here is how mine is looking: angular.module .controller('MyCtrl', MyCtrl) ; MyCtrl.$inject = ['service1', 'service2', ...
0
votes
1answer
70 views

AngularJS[$injector:unpr] Unknown provider

Can somone offer me insight on why I am getting the error in the title based on my code? Not quite sure why. angular.module("demoApp", ['ngRoute']) .config(['$routeProvider', '$locationProvider', ...
0
votes
2answers
2k views

Module is not available, misspelled or forgot to load (but i didnt)

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 ...
0
votes
0answers
37 views

Error injecting angular $location service

I need to use $location service inside my jQuery(callback) function, so I tried to do the following: $(function(){ ... some stuff ... var $injector = angular.injector(['ng']); ...
0
votes
1answer
215 views

I can't get where that “Error: $injector:unpr Unknown Provider” is from

All works fine if I don't inject into controller "getChildrenNumber", after then I get the error from $injector. I've read even this https://docs.angularjs.org/error/$injector/unpr, but it seems not ...
1
vote
1answer
17 views

Once I turn off debuggingData in angular, is there another way to get the rootscope?

I think having debugging info on by default in Angular will sink large apps. You can now disable this in production: https://docs.angularjs.org/guide/production#disabling-debug-data But there are ...
0
votes
2answers
57 views

How do i use $location in a normal function

I have a angular app where half is angular js and half is plane js like ajax. So how do i use $location inside that function without passing it as a function parameter. function x() { ...
0
votes
2answers
80 views

How to include and use ui-router in my app without injector errors?

UPDATE I've reverted back to a state before including any ui-router I was getting that terrible $injector error that I could not solve, I've since reverted back and need to know how to simply ...
-1
votes
1answer
70 views

Custom data annotation to hide property based on another's value

Having a nightmare figuring this out and I am now flat against the brick wall Using MVC framework I'm building essentially a simple form. I'm keeping the view as simple as possible and using just ...
0
votes
1answer
107 views

AngularJS access parent scope

I'm new to angularjs and I'm trying to do some things that I don't know if is a good practice. Well, I have a main page where I want to show the messages of all other controller and views. In this ...
0
votes
0answers
20 views

Angular1 Injector - not refreshing list of services/directives/fitlers

In our app, we need to work with angular injector, and I have a problem with it, because it's not updating the list of services/directives/controllers as I am registering them in my app. Take this ...
0
votes
2answers
470 views

Where is my Angularjs minify error? Error $injector

I'm running into that annoying Angular minify problem (I really hope this issue is non-existent in Angular 2) I've commented out all my app module injections and going down the list 1 by 1 to find ...
5
votes
1answer
82 views

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 ...
4
votes
2answers
205 views

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. ...
3
votes
2answers
166 views

$provide outside config blocks

I'm certainly missing some fundamental point about the injector, but I fail to understand why exactly this angular.module('app').config(function ($provide) { ... }); and this ...
4
votes
1answer
103 views

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 ...
0
votes
1answer
82 views

Unknown provider: userFactoryProvider <- userFactory <- userController

Initially, I made a controller to keep the data for me and It was working for me. then I moved my data to a factory. I injected my factory to the controller. I also putting the address of my ...
2
votes
2answers
42 views

AngJS - Get the injected dependencies list

Just suppose I created a service like this: .service('foo', ['bar', function(bar){ //var deplist = *something* for(..){ deplist[..].method(); } }]); Is there any way to retrieve a list of ...
0
votes
3answers
123 views

When to use $injector in AngularJS

As I'm parsing through AngularJS documentation, I thought I would post this to get some other opinions. My specific scenario is that I have settings I wish to change on an injectable using the run ...
0
votes
0answers
116 views

Modify or access angular interceptors after config phase

Is it possible to access / modify $http interceptors after the config phase? I'm debugging an app that only breaks in production due to being deployed on a different server, so unfortunately I can't ...
5
votes
2answers
2k views

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: ...
1
vote
2answers
479 views

Wait for Provider to finish before entering State

I'm trying to wait for the provider to finish initializing before ui-router goes on to load the state. Every time you enter the state the camera should be enabled, and whenever it is left disabled ...
1
vote
2answers
671 views

Unknown provider in .config() with custom Provider

I've got this in app.js: angular.module('App',[]).config(['TranslationProvider', function (TranslationProvider) { //codes... }]); And this service in another file: angular.module('App') ...
2
votes
1answer
379 views

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 ...
1
vote
1answer
115 views

IIFE breaks interceptor - unknown provider

I'm using an interceptor to add JWT tokens to my http calls. My code works fine like this: angular .module("jwtKickStart") .factory("authInterceptorService", authInterceptorService); ...
0
votes
1answer
50 views

How to uninject a dependency previously included using $inject in AngularJS

I've been reading the official docs https://docs.angularjs.org/api/auto/service/$injector but failed to find how to de-inject a dependency. My scenario: I have a service that authenticates users, ...
3
votes
1answer
842 views

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 ...
1
vote
0answers
199 views

How to inject $location into a click event handler defined in a config function

I am amending some code that is a plugin to an AngularJS analytics framework. In the plugin, I would like access to the $locationobject within what is essentially a $routeChangeSuccess handler. The ...
2
votes
4answers
1k views

: [$injector:unpr] Unknown provider in angularjs can't inject factory into controller

I have an unknown provider error and I'm not sure how to solve it. I think my services, controllers are declared properly. I have tried everything but it doesn't work. my photosFactory factory doesn't ...