javascript - AngularJS dependencies: constant / controller etc. not loaded in a module -


i've stumbled upon this question here looking reason, defined factory not loaded. wondered terms "defined in angular module".

if have kind of service this:

angular.module('d3', ['underscore'])        .factory('d3', ['$window', 'underscore',        function($window, _) {            if (!_.isobject($window.d3)) {                throw "services.d3: moment library missing!";            } else {                return $window.d3;           }        }    ]); 

and when try load service in module this:

angular.module("widgets.d3widget", ['underscore'])  .controller("widgets.d3widget.d3widgetctrl", [     "$scope",     "d3",     function(         $scope,         d3     ) {         console.log(d3.select('body'));         //work goes here     } ]); 

the service not loaded. rather angular error like: "error: [$injector:unpr] unknown provider: d3provider <- d3.

i've read angular docu di, didn't much.

so meant 'defining service'? writing module d3 seems not enough, need add in second module, angular.module("widgets.d3widget", ['underscore', 'd3']), not in component of module (controller, directive, whatever). right?

sorry, cannot post comments. need add 'd3' dependency when configuring module widgets.d3widget, this

angular.module("widgets.d3widget", ['d3']) 

this because 'd3' not residing under same module 'widgets.d3widget'.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -