我正在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
是的,這是我得到的 –