Module not found in angularjs Module not found in angularjs angularjs angularjs

Module not found in angularjs


Many has fallen into the same trap. Me included.

The following does not define a new module. It will try to retrieve a module named UserHandler which isn't defined yet.

angular.module('UserHandler')

Providing a (empty) array of dependencies as the second argument will define your module.

angular.module('UserHandler', [])


I am new to javascript and have spent a couple of hours to discover my issue. The module initialization function can be ignored. To avoid this, do not forget to add empty parenthesis to the end of a function:

(function() {    "use strict";    var app = angular.module("app", []);    })(); //<<---Here


Also, don't forget to add the new module in your index.html:

<script src="app/auxiliary/test.module.js"></script><script src="app/auxiliary/test.route.js"></script><script src="app/auxiliary/test.controller.js"></script>