The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
825
votes
14answers
187k views
AngularJS: Difference between angular-route and angular-ui-router
I am new to AngularJS. I find AngularJS quite interesting and am planning to use AngularJS in my big applications. So I am in the process to find out the right modules to use.
What is the difference ...
61
votes
8answers
61k views
is there a way in Angularjs to define constants with other constants?
I'm trying to define constants with other constants, but it seems that it can't be done, because the initial constant isn't ready when the required constant depending require it. I want to be sure if ...
38
votes
3answers
11k views
Modules and namespace / name collision in AngularJS
Consider the following jfiddle http://jsfiddle.net/bchapman26/9uUBU/29/
//angular.js example for factory vs service
var app = angular.module('myApp', ['module1', 'module2']);
var service1module = ...
34
votes
6answers
17k views
How to check for the existence of a module without an error being raised?
In Angular 1.2, ngRoute is a separate module so you can use other community routers like ui.router instead.
I'm writing an open-source module that aims to work for multiple different router ...
26
votes
2answers
2k views
AngularJS - module dependencies, naming clash
I have two third-party modules, both defining a factory with the same name. Obviously, I don't have any control over the naming of those modules without resorting to a kludge.
Additionally, I have ...
22
votes
1answer
9k views
How to use two AngularJS services with same name from different modules?
Supposed I have two modules for AngularJS, e.g. foo and bar, and both of them define a service called baz.
In my application I depend on them by saying:
var app = angular.module('app', [ 'foo', 'bar'...
19
votes
5answers
14k views
Is it possible to override constants for module config functions in tests?
I've spent quite a while banging my head against trying to override injected constants provided to modules' config functions. My code looks something like
common.constant('I18n', <provided by ...
18
votes
1answer
8k views
How to share data between two modules in AngularJS?
I am using AngularJS along with c# mvc. I have a home page where user enters some data and that should be passed to the second module where I use this data for processing and decisions. I have to use ...
17
votes
5answers
76k views
AngularJS: Uncaught Error: [$injector:modulerr] Failed to instantiate module?
I am new to AngularJS and working my way through some documents and tutorials to learn. My question is in reference to Egghead's video series, this video in particular, demonstrating how to put ...
15
votes
1answer
6k views
How to declare sub-modules in AngularJS
When working on large projects in AngularJS, I found that I like organizing code by functionality.
That means that when I have some recognizable functionality X (especially if it is reusable) I create ...
13
votes
2answers
9k views
Module not found in angularjs
I want to wrap this https://gist.github.com/nblumoe/3052052 in a module. I just changed the code from TokenHandler to UserHandler, because on every api request I want to send the user ID.
However I ...
13
votes
2answers
9k views
Using a factory inside another factory AngularJS
I have a module...
angular.module('myModule', []);
And then a factory
angular.module('myModule')
.factory('factory1', [
function() {
//some var's and functions
}
]);
And then another factory
...
9
votes
2answers
18k views
AngularJS Modules/Scope Sharing
I recently started using AngularJS and the way I'm building my apps now is like this:
MainController.js
var app = angular.module('app', ['SomeController', 'MainController']);
app.controller('...
9
votes
1answer
1k views
How should I make configurable modules in AngularJS
I've been tinkering with AngularJS and I've built up a small collection of directives and services that I would like to package into a single JS file so that I can use them anywhere.
I have some ...
8
votes
1answer
4k views
Angularjs - how to correct inject service from another module that is not depending?
I didn't understand how work modular depending.
I have 4 modules, they are dependent on each other, as shown in the picture.
"App" module includes "module1" and "module2".
"module2" includes "core" ...
7
votes
2answers
74 views
List dependencies injected
Is there a way to know what dependencies were injected into my Angular module?
angular.module('myModule', [
'ui.bootstrap'
])
.controller('myController', [function () {
// var dependencies = ...
6
votes
1answer
6k views
Dependency errors in Angular when creating an $http interceptor as a standalone module
Here is a working example of how I have set up an interceptor which attaches an authentication token to each request (this is more or less the example from https://docs.angularjs.org/api/ng/service/$...
6
votes
2answers
1k views
Angular Module Private Members
In AngularJS, is it possible to create private controllers or services which can be used within the module they are defined in, but not by another module they are injected into.
For example, can ...
6
votes
1answer
288 views
Why must a provider be defined before a config block
I have a module. It has a config block, a provider, and a constant defined. The config block references both the constant and the provider. I notice that my constant can be defined before or after ...
6
votes
2answers
1k views
AngularJs Lazy Loadng without RequireJS
In a large scale application, How do we lazy load modules, controllers, services whenever needed without loading those in the index.html. Here I'm referring to load the entire js in the relevant ...
5
votes
2answers
55 views
controller function in angularjs?
I am new to angular js
Controller is not working correctly in my code
i am trying to run following code
<!DOCTYPE html>
<html data-ng-app >
<head>
<title>Using AngularJS ...
4
votes
5answers
530 views
Angular.js Controller Not Working
I'm new to Angular and I'm going through the Intro to Angular videos from the Angular site. My code isn't working and I have no idea why not. I get the error
Error: ng:areq
Bad Argument
Argument '...
4
votes
1answer
3k views
AngularJS: uncaught object because of services and modules dependencies
I have a 'maps-services' module with a 'MapService' service as below:
angular.module('maps-services', [])
.service('MapService', [$log, function($log) {
this.initMap = function() {
}
this....
3
votes
3answers
80 views
Where is the controller in this simple AngularJs page?
I am told that every AngularJS page with the ngApp directive has a controller, providing for $scope. In the earliest, simplest example given by the W3Schools site the code has no ngController tag:
&...
3
votes
2answers
775 views
How module have access to another module even though it has no dependencies
I'm a little confused about how modules load in angular. Take for example the following code:
var app = angular.module("app", [ "app.widgets", "app.core"]);
var core = angular.module("app.core", ...
3
votes
1answer
2k views
Angularjs Uncaught Error: [$injector:unpr]
I am developing shoping website with java and I am using angurajs.
I have problem with thise files:
DashboardControll.js
'use strict';
var app = angular.module("DashboardApp", []);
app....
3
votes
1answer
2k views
Creating virtual keyboard as a AngularJs module?
I have a AngularJs app and I need to create a virtual keyboard. The keyboard should be a separate module. My problem is that I am not sure how to properly structure my module? Should it be implemented ...
3
votes
1answer
4k views
angular module is not available
This is surely a noob question but I just can't seem to figure out what is wrong with this simple module initiation (JSFiddle):
var myApp = angular.module('myApp', []);
I get an error saying that "...
3
votes
1answer
654 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 ...
3
votes
1answer
89 views
Add modules to my Angular App Dynamically
How can I load my modules(selected based on user after logged in) in my Angular app dynamically?
3
votes
2answers
298 views
When pulling angularjs controllers out into different files, what if my module doesn't load first?
When my module does not load how can I load it correctly?
Suppose I have tens of controllers and I would like to separate each controller into its own file. For this example suppose I have one ...
2
votes
3answers
2k views
Meaning of the empty array in angularJS module declaration
In my previous question, I understand that the code var app = angular.module('myApp', []); connects the module app to the view myApp.
I would like to know why we are having the empty array [] in the ...
2
votes
1answer
1k views
karma.conf.js uncaught referencerror: google no defined
when i try running the karma test runner, i'm getting a error as the following from one of my files, saying that my library google is undefined???
Chrome 36.0.1985 (Mac OS X 10.9.4) ERROR
...
2
votes
3answers
6k views
spreadsheet module for angular JS
I am looking for a spreadsheet component to use in an Angular JS application. I found a tutorial on the web about making a spreadsheet using angualr, but I want something more advanced, for example ...
2
votes
1answer
622 views
Dynamically register directive at runtime
Normally, directives are registered on a module by using the directive method:
.directive('MyDirective', function (MyDep) {
return {
restrict: 'E',
template: '<div></div&...
2
votes
2answers
3k views
Correct way of wrapping javascript class in AngularJS module and inject angular services
Inside an AngularJS module I'm developing, I have a Canvas class defined as:
angular.module("myModule", [])
.factory("Canvas", function() {return Canvas;});
var Canvas = function(element, options) {
...
2
votes
1answer
871 views
AngularJS Error: $injector:unpr Unknown Provider githubProvider <- github <- MainController
I'm trying to build my own service by following the example in the documentation for the factory methodology. I think I've done something wrong however because I continue to get the unknown provider ...
2
votes
1answer
185 views
Vanilla AngularJs not loading up.
I am new to Angularjs. Trying to make a basic application. Getting stuck.
I loaded the angularjs
<script type="text/javascript"
src="https://code.angularjs.org/1.4.8/angular.min.js"></...
2
votes
1answer
110 views
How to fix an angular.module not working with dependent modules?
I'm pretty clear on how angular.module works, but this eludes me for whatever reason.
In my code I have the following
var app = angular.module("myApp", [])
app.controller("MainCtrl", ...)
but my ...
2
votes
3answers
181 views
Configuring AngularJS modules - how does it affect the other modules in the app?
I have two Angular modules, A and B.
A has no deps, some configurations and some filters:
angular.module('A', [])
.config(function ($httpProvider) {
// set common headers for $http requests
...
2
votes
1answer
52 views
How do you design a module that a user has to pass config data to when they depend on it?
I have an angular module that is basically a client side web service layer (work in progress). I have a module declaration, and a factory called "baseRequest". baseRequest is depended on by other ...
2
votes
1answer
168 views
AngularJS module dependency injection sharing its dependencies with parent module
I have an AngularJS module:
angular.module("app", ['ui.bootstrap', 'ngRoute', 'ngGridPanel']).config(function($routeProvider) {
As you can see it has ngGridPanel included via dependency injection.
...
2
votes
2answers
1k views
angular wait for parent controller
I have an angular application and several modules.
As you can see below, i am calling a directive that in mod2, at the mod1template.html.
myvar gets value in mod1Ctrl
But angular initialize child ...
2
votes
2answers
81 views
Angularjs Modules - Packaging Directives and Their Controllers
I have the following javascript code and i ran into a issue:
My .js file
angular.module('MyApp',['ngMaterial','ngMessages'])
.controller('MainCtrl',['$mdDialog',function($mdDialog'){
this.openDialog ...
2
votes
1answer
28 views
Dependencies within the module dependencies?
If mainApp has dependencies on module app1, app2, like angular.module("mainApp", ['app1', 'app2']), this does not imply the dependencies between app1 and app2, right? Or say, this does not mean ...
2
votes
0answers
38 views
Should I use only one single module in angularjs
I want to know what're the drawbacks of declaring and using ONLLY ONE module in my SPA?
Does it reduce testability?
Does it impact the performance?
Does it make code less readable or maintainable?
...
2
votes
0answers
335 views
How to setup the dependency for the Forge library?
I am trying to include this library (Digital Bazaar / Forge) in my project:
https://github.com/digitalbazaar/forge
To include the dependency and have the forge object available through my angularjs ...
2
votes
1answer
508 views
AngularJS module .run order and e2e mocks
I am working on some E2E tests for AngularJS.
I have implemented a $httpBackend ngMockE2E.
This works well, however in some instances HTTP requests are being made before my mocks have been ...
1
vote
5answers
2k views
How can I have multiple controller files?
SOLVED
So after viewing your responses and making minor changes to my code, I found a simple typo which prevented me to reach the result I was after. So thank you all to helping with where I was ...
1
vote
3answers
4k views
How do you change the ng-model attribute of an element (and have it work)?
I have an input with an ng-model attribute set to "search.name"
HTML
Search:
<span id="searchName"> titles </span> | <span id="searchSpecies"> species </span>:
<input ...