Fix AngularJS Bootstrap Module Initialization Error

If you are new to using angularJS one of the common errors you may run into looks like below.

Unhandled exception at line 3809, column 9 in http://localhost:15396/Scripts/angular.js
0x800a139e - JavaScript runtime error: [$injector:modulerr] Failed to instantiate module 
   AngularWebPortal due to:
Error: [$injector:nomod] Module 'AngularWebPortal' 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 not very serious error. This error simply means that in my page you have defined ng-app directive with a value of AngularWebPortal but I never created module using that directive. This directive is used to create bootstrap root of the application. You can read more about it here.

The fix is very simple. Just create a module that uses that root element directive and you are good to go.

<html ng-app="AngularWebPortal"> ..... </html>

In javascrit file:

 var WebPortal = angular.module("AngularWebPortal", []);
comments powered by Disqus

Search

Social

Weather

9.2 °C / 48.5 °F

weather conditions Clouds

Monthly Posts

Blog Tags