AngularJs - Injecting child module into other child module -


i have scenario might sound stupid i'm stuck , trying understanding might causing not work.

i have angular app has 3 modules now

var app = angular.module('mainapp', ['ngroute']); //parent module var reviewmodule = angular.module('reviewmodule', ['mainapp']);  //child 1 var searchmodule = angular.module('searchmodule', ['mainapp']);  //child 2 

i have set configurations , default strings in parent module (which mainapp) want use in child modules.

on other hand, reviewmodule , searchmodule (child modules) have separate controllers , services i'm using on different routes. now, problem comes when want use 1 module's service other example if following

var searchmodule = angular.module('searchmodule', ['mainapp', 'reviewmodule']); 

to use reviewmodule services in search module controllers, exception says

error: $injector:modulerr module error failed instantiate module searchmodule 

both child modules have same parent , want use 1 child module other child module , couldn't understand why i'm getting exception.

update:

i tried using line below module declaration

var searchmodule = angular.module('searchmodule', ['reviewmodule']); 

but causes exception too.

this backwards .... add secondary modules dependencies of main module

angular.module('reviewmodule', []);   angular.module('searchmodule', []);    angular.module('mainapp', ['ngroute','reviewmodule', 'searchmodule']); //parent module 

all components of modules available anywhere across app

alternatively have 1 child load dependency end result need bound main application module gets bootstrapped

example:

angular.module('reviewmodule', []);   angular.module('searchmodule', []);   // module combine other modules angular.module('mychildmodules',['reviewmodule', 'searchmodule']); // add combined modules dependency of main app module angular.module('mainapp', ['ngroute','mychildmodules']); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -