我有这个错误,我不知道如何解决它们,如果你能帮助我的话 我的页面html是按照
<html ng-app="app">
...
<div ng-controller="codeCtrl">
<textarea ui-codemirror ng-model="code">{{ code }}</textarea>
</div>
我的代码js如下:
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 "do what I mean"/em>... but might not match your style. </body> </html>';
};
我接受了这个错误
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
答案 0 :(得分:0)
似乎依赖项[ui]
未包含在您的网页上并已实例化,
当你想编写控制器时,你需要这样写:
function codeCtrl($scope) {
$scope.code= '<html style="color: green"> <head> <title>HTML Example/title> /head> body> The indentation tries to be <em>somewhat "do what I mean"/em>... but might not match your style. </body> </html>';
};
myApp.controller('codeCtrl',codeCtrl);
答案 1 :(得分:0)
我错过了在我的html页面中包含js脚本, 我建议使用[&#39; ui.codemirror&#39;]代替[&#39; ui&#39;]
感谢您的回答