darkman darkman - 1 month ago 18
AngularJS Question

Error: [$injector:modulerr] Failed to instantiate module app

I have this error and i dont knew how to resolve them, if you can help me
My page html is follow

<html ng-app="app">
...
<div ng-controller="codeCtrl">
<textarea ui-codemirror ng-model="code">{{ code }}</textarea>
</div>


and my code js is follow:

var myApp = angular.module('app', ['ui']);

myApp.value('ui.config', {
codemirror: {
lineNumbers: true,
htmlMode: true,
mode: "text/html",
theme: "ambiance",
indentWithTabs: false,
readOnly: true,
matchBrackets: true
};
});

function codeCtrl($scope) {
$scope.code= '<html style="color: green"> <head> <title>HTML Example/title> /head> body> The indentation tries to be <em>somewhat &quot;do what I mean&quot;/em>... but might not match your style. </body> </html>';
};


i take this error

Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:nomod] Module 'app' 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.10/$injector/nomod?p0=app

Answer

I have missed to include js script in my html pages, and i suggest to use ['ui.codemirror'] instead ['ui']

Thank you for your answers