Error: [$injector:nomod] Module ‘ngRoute’, ‘ngResource’ is not available

Problem

Uncaught Error: [$injector:modulerr] Failed to instantiate module clientApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' 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.
http://errors.angularjs.org/1.2.6/$injector/nomod?p0=ngRoute

or for ngResource:

 

Uncaught Error: [$injector:modulerr] Failed to instantiate module clientApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngResource due to:
Error: [$injector:nomod] Module 'ngResource' 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.
http://errors.angularjs.org/1.2.6/$injector/nomod?p0=ngResource
    at http://localhost:9000/webjars/angularjs/1.2.6/angular.js:78:12
    at http://localhost:9000/webjars/angularjs/1.2.6/angular.js:1526:17
    at ensure (http://localhost:9000/webjars/angularjs/1.2.6/angular.js:1451:38)
    at module (http://localhost:9000/webjars/angularjs/1.2.6/angular.js:1524:14)
    at http://localhost:9000/webjars/angularjs/1.2.6/angular.js:3614:22
    at Array.forEach (native)
    at forEach (http://localhost:9000/webjars/angularjs/1.2.6/angular.js:302:11)
    at loadModules (http://localhost:9000/webjars/angularjs/1.2.6/angular.js:3608:5)
    at http://localhost:9000/webjars/angularjs/1.2.6/angular.js:3615:40
    at Array.forEach (native)

Solution

ngRoute (similarly for ngResource) must be imported separately (as of version 1.2):

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular-route.js"></script>

or a preferred way is with awesome webjars

<script src="@routes.WebJarAssets.at(WebJarAssets.locate("angular-route.js"))"></script>

for webjars also don’t forget to update Build.scala with:

"org.webjars" % "angularjs" % "1.2.6"

 

About Neil Rubens

see http://ActiveIntelligence.org
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Error: [$injector:nomod] Module ‘ngRoute’, ‘ngResource’ is not available

  1. Miguel Mota says:

    This solved my issue, thanks!

  2. Jason Godinho says:

    Just couldn’t figure out why ‘ngroute’ was failing until I saw this post. Thanks alot

Leave a Reply

Your email address will not be published. Required fields are marked *


*