我正在mvc-angularjs中创建一个web应用程序,我正在使用ngroute。这个名字的控制器没有在angularjs ngroute中注册
<div class="container body-content" ng-app="MyApp">
<br />
<br />
<br />
<div style="float:right;">
<a href="#" class="btn btn-danger">Sign Out</a>
</div>
@RenderBody()
<hr />
</div>
<script>
(function() {
var app = angular.module('MyApp', ['ngRoute', "ngStorage"]);
app.controller('myctrllayout', function ($scope) {
});
})();
</script>
,这是我的欢迎页面:在我的布局与HTML代码
Angularjs控制器
<div ng-controller="welcome">
</div>
<script>
angular.module('MyApp',[])
.controller('welcome', function ($scope) {
});
</script>
,当我跑我得到了以下错误代码
Error: $controller:ctrlreg A controller with this name is not registered.
The controller with the name 'welcome' is not registered.
当我将我的应用程序从('MyApp',[])
更改为('MyApp')
时:
Module 'MyApp' 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.
模块'MyApp'不可用!您拼错了模块名称或忘记加载模块名称。如果注册模块确保您指定依赖关系作为第二个参数。 这是我得到的错误 –
这是你从我的答案更新代码后得到的错误? – Korte
是的,这是我得到的 –