0
votes
1answer
26 views

Angular js - services and circular injection error

Why does i can't inject services like this? service('actionService',function (sessionService) { this.doAction = function () { return 5; } }); service('sessionService',function (userService) { ...
0
votes
2answers
9 views

Auto-create service instance in AngularJS (no lazy-load)

I've created a service that needs to listen for $route events. I'm setting listeners with $rootScope.$on(). My service looks like this: application.factory('myListener', ['$rootScope', function ...
1
vote
1answer
29 views

Grunt.js for Angular.js dependency injection management

I am using Grunt to automatically build my web app. I have run into an interesting issue. I have two options: 1)grunt:dev and 2)grunt:build grunt:dev just does basic tasks related to development. My ...
0
votes
1answer
31 views

How to inject my service into my controller angular js

I am relatively new to angular JS and I have an issue with angularJS 1.3.0 beta build I am trying to insert my service (a standalone module) to a controller. This is my app Code 'use strict'; ...
0
votes
1answer
20 views

AngularJS Dependency Injection Principle

What is the magic behind auto resolving dependencies in AngularJS? angular .module('app', []) .service('appService', function appService (firstService, secondService, thirdService) { ...
2
votes
1answer
35 views

Is it possible to inject a dependency “everywhere” automatically?

This may seem like a stupid question but I got ask... I have something like this: APP.constant('MyGlobalConstants', { }); Is there any way that I can inject MyGlobalConstants automatically in all ...
0
votes
1answer
42 views

Understanding injection dependency in app and tests in AngularJS

I have a dependency injection (understanding) problem while testing a directive (AjaxLoader displayed only when there is a pending request). App declaration : angular.module('app', [ ...
0
votes
1answer
20 views

AngularJS Dependency Injector

I've been using angularJS for a while now, and I was wondering if it is correct to use the DI this way. Let's say I want to define a service, which needs some angular services. I would probably write ...
0
votes
2answers
80 views

Angularjs minification using grunt uglify resulting in js error

In angularjs we pass parameters as dependency injection. For example, function checkInCtrl ($scope, $rootScope, $location, $http){ ….. …. } So when it gets minified, it becomes like, function ...
0
votes
2answers
32 views

How to inject datefilter in protractor?

I am writing end to end test cases for my angular application. I need to check for dates that are in correct format. So I want to inject the 'datefilter', so that I can use it in protractor. When i ...
0
votes
2answers
77 views

AngularJS and Typescript - Services injected into other services are undefined

I'm using this starter template with the modifications outlined in this SO post. It has been smooth sailing until now - I'm trying to inject a service into the constructor of another service, but the ...
0
votes
0answers
20 views

Injecting an annotated Service in a Provider in Angular

I would like to use a Service in a Provider. I'm not sure it's the right way to go. I've managed to instantiate a service in a provider, by injecting the service provider instead, and calling its ...
0
votes
1answer
23 views

Angularjs module dependencies loop

I am curious and still can not explain dependency loop (passed) in this case. angular.module('mainApp', ['addon.dashboard']).factory('Test', function(){ return { hello: 'moto' }; }); ...
2
votes
2answers
49 views

Angularjs : How to switch between different implementations of a provider using DI

First I'd like to say my appreciation for this great website that I rely on rather often but never have used to ask anything. I'm currently learning AngularJS by reading "Mastering web application ...
0
votes
1answer
15 views

Why angular.injector(), when we have angular.module('moduleName', [<Dependencies If any>]);

everybody, As you can see the title, i have to confirm my understanding, that If we have : angular.module('moduleName', [<Dependencies If any>]); Then, do we really need this ...
1
vote
1answer
26 views

AngularJS - Dependency injection involving asynchronous data

I want to make the currently logged in user's ID and user name available to my Angular directives. I have created an API end-point to retrieve this information (along with some other information). ...
0
votes
0answers
30 views

Dependency on service/factory with same name from different module

I am trying to create a service in a module which is dependent on another service in another module but the services have the same name. Consider the following example: ...
1
vote
1answer
51 views

Get a hold of an object (function of controller, service or directive) from another module

Is it possible to access functions that sit either in the same module or in a different one? Something like: var fooDir = angular.module("directives").get("foo") … or: var myCtrl = ...
0
votes
3answers
74 views

Injecting services/constants into provider in Angularjs

The problem here is I am able to access the getRoutes(), but I am unable to access the injected constant -"configuration". What am I missing? Thanks. (function () { 'use strict'; var app = ...
0
votes
1answer
30 views

Dependency's break the app [closed]

I have a fairly small angular JS app, it works great but I would like to add some dependency's for instance bootstrap.ui. That's the start of my module, this works great! ...
1
vote
1answer
58 views

Where is my dependency injection going wrong in my angular application

To begin with angular.module('app', [ 'ngCookies', 'ngResource', 'ngSanitize', 'ngRoute' ]) Here is my casual factory. Nothing really to see angular.module('app') .factory('myFactory', ...
0
votes
2answers
27 views

App not working if dependency left blank, working if dependency completely removed

I have a simple Angular app, calling a controller, which in turn calls a service. This service then loops through an array and returns a few strings. If I leave the dependencies on the ...
0
votes
1answer
26 views

unknown provider, service isn't being injected

I'm confused about how to create services and inject (use) them in my controllers. It seems it is very simple but I can't get my code to work. I'm stuck with this error: Error: [$injector:unpr] ...
1
vote
0answers
57 views

AngularJS Provider dependency injection - using $http in provider?

tl;dr I'm really struggling to find the appropriate pattern here. How should I best configure a generalized provider to a specific use-case? I can't use $http as a dependency in .configure(); can I? ...
2
votes
1answer
69 views

Differences between AngularJS injector and NodeJS require module

I have a question around the dependency injection based on AngularJS and NodeJS. There's any difference between $injector from AngularJS and the require module from NodeJS? Would be nice use require ...
0
votes
1answer
20 views

Is it possible to have a provider, which will provide a different implementation based on who is using(injecting) it?

Specifically, I want to write a logging service in Angular, which would ideally have a setting for each of my services and factories like this: { myService1: true, myService2: false, ...
0
votes
2answers
214 views

Promise dependency resolution order in angular ui-router

I have set up a top-level controller that is instantiated only when a promise (returned by a Config factory) is successfully resolved. That promise basically downloads the Web app configuration, with ...
0
votes
1answer
19 views

Any way to inject dependecies into controller with silent error in case no matched provider found out

Is there any way to do the following case using annotation style injection with no provider exception just null references. ...
0
votes
2answers
55 views

Turn off implicit dependency injection in AngularJS

I am trying to debug a missing provider in a large-ish AngularJS project. The error is a missing 'dProvider'. It is only occurring on a version of the code that is minified, which makes sense, ...
2
votes
1answer
62 views

Is there a convention of formatting injected dependencies?

Angular JS Dependencies Are there any commonly accepted conventions for how to format long lists of dependencies when using inline bracket notation? After browsing through github and the Angular JS ...
0
votes
0answers
25 views

AngularJS - DI injection - substitute service

Here is my application module definition: angular.module('myApp', ['userMod', 'galleryMod']) // main application I have a user module: angular.module('userMod', []); ...
0
votes
1answer
51 views

AngularJS - is it dependency injection or multiple inheritance?

Most of the documentation I have read regarding AngularJS talks about dependency injection. When defining a controller, you can inject other classes into it, making their operations/properties ...
2
votes
1answer
96 views

Custom directives on AngularJS pages without specific ng-app module set

I have some simple pages that don't need a specific application module to be provided in the ng-app attribute. But those pages also use some of my custom directives. As it seems natural I've put all ...
0
votes
1answer
69 views

Why is the function in angular's DI inline annotation a array element?

I have a question for the angularjs folks here. So, I am using angular for quite a while now. However, every time when I am writing a new Controller or something that is using dependency injection, ...
0
votes
1answer
48 views

Compositional approach to build an application with Angular

How to connect angular controllers using data from HTML code? I have a server-side framework, which allows me to build an application by connecting components together. Some of these components get ...
0
votes
0answers
26 views

Unknown provider: productProvider <- product

I have a strange problem with Angularjs i have an Unknown provider: productProvider <- product error in my Controller. The product variable i am injecting is filled i can see this in the log. In ...
0
votes
2answers
66 views

How can you ensure that angular module dependencies get resolved?

Angular's documentation on modules (http://docs-angularjs-org-dev.appspot.com/guide/module) says: Dependencies Modules can list other modules as their dependencies. Depending on a module ...
0
votes
1answer
41 views

Does specifying dependency as string make DI faster in AngularJS?

The angular docs say that it supports these two forms of DI setup (plus another, but it's not necessary for this question): with var app = angular.module('MyApp', []); you can 1. ...
1
vote
1answer
680 views

How to inject a controller into a directive when unit-testing

I want to test an AngularJS directive declared like this app.directive('myCustomer', function() { return { template: 'cust.html' controller: 'customerController' }; }); In the ...
0
votes
1answer
686 views

AngularJS: inject service into directive?

I've been trying to integrate D3.js with Angular, and am following this tutorial: http://www.ng-newsletter.com/posts/d3-on-angular.html The tutorial creates a d3 module which contains d3Service, and ...
0
votes
0answers
40 views

Angularjs access a service without injection?

Hi I am trying to build configurable components/directives. This directive will basically accept objects and populate itself. I want to pass the name of the service that will pass the json object to ...
0
votes
1answer
57 views

Don't execute .run() until AngularJS service ($) is available

Following on from my previous question: Adding a Self-Executing Anonymous Function to extend Sir Trevor in AngularJS whilst accessing $ I run some configuration code to extend the Sir Trevor Content ...
0
votes
0answers
25 views

Dependecy trouble when testing AngularJS with Karma

I'm having trouble with dependencies in Karma test scenario. When preparing environment looks like this: beforeEach(module('printecAdminApp')); beforeEach(inject(function(restService) { ...
0
votes
2answers
48 views

Aliasing $scope in angular

I'm trying to create an adaptor for angular so that my services,controllers etc.. can use generic names its features, and then if I change to use another mvc library in future, or want to use my ...
0
votes
1answer
58 views

AngularJS override service injection in some cases

I have an angular service (let's call it $superService), and I use it in lots of my directives, controllers etc. But I also have one specific directive that I would like to have the following ...
2
votes
3answers
106 views

Manual injection in Dart

How do you manually inject an instance in angular dart? This would be the equivalent to the following in angularjs: var myInjector = angular.injector(["ng"]); var $http = myInjector.get("$http");
0
votes
3answers
131 views

AngularJS - Injecting a Provider

EDIT: using YEOMAN to scaffold my app, I have the following YEOMAN generated provider 'use strict'; angular.module('myApp') .provider('myProvider', function () { // Private variables ...
1
vote
1answer
60 views

Why doesn't the default Yeoman app module need an empty array for dependencies injection?

I know this feels like a silly question but it really bothers me. I've learned when declaring a module in angular, that one must put an empty array, regardless of there being a dependency needed. ...
1
vote
1answer
177 views

Stuck with “Unknown provider” error when attempting to inject dependency

I'm trying to unit test an Angular service, using Jamsine, and I'm stuck on how to inject the dependency for that service. Here is my app.js file, trimmed down to the essentials: "use strict"; ...
0
votes
1answer
624 views

How do I inject a mock dependency into an angular directive with Jasmine on Karma

I have the following directive: function TopLevelMenuDirective ($userDetails, $configuration) { return { restrict:'A', templateUrl: staticFilesUri + ...