Failing to inject new modules to main app module.
Hello there,
First, kudos for the generator, its really nice.
While setting up the environment, I tried creating a new module but when I ran gulp serve, the chrome console threw up an error :
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myOwnModule due to:
Error: [$injector:nomod] Module 'myOwnModule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
This is myOwnModule file:
angular
.module('myOwnModule', [])
.controller('SidebarCtrl', SidebarCtrl);
/* @ngInject */
function SidebarCtrl($timeout, toastr) {
'ngInject';
var vm = this;
vm.text = "someRandomText";
}
and the dependency injection on index.module.js :
angular.module('myApp', ['myOwnModule', 'ngAnimate', 'ngCo...
What am I doing wrong?
Upon further investigation, I came to understand the .js files were not being injected anywhere in the /tmp files. Why are they not being injected? Isn't there a gulp task to do the upmentioned?
Hi altinselimi
You're close - the problem seems to be with gulp/inject.js. Creating a new 'best practice'. module directory gave me the same error when the file was named mynewmodule/mynewmodule.module.js but after renaming it mynewmodule/mynewmodule.js it all worked fine with a .controller and .directive set to angular.module('mynewmodule'). ... in new .js files.
I'm pretty sure this is because the default (line 25) in gulp.inject.js is
path.join(conf.paths.src, '/app/**/*.module.js')
because if you change that to
path.join(conf.paths.src, '/app/**/index.module.js')
then
mynewmodule/mynewmodule.module.js and everything else runs without errors.
Hope that helps (and yes I agree, it's a great generator and the Fuse admin theme built on top of it with ui-material is also pretty cool)
and, of course, if you edit a gulp file you need to run gulp serve again...