I am creating a web application in mvc-angularjs, I am using ngroute.
Angularjs controller in my layout with html code:
<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>
and this is my welcome page:
<div ng-controller="welcome">
</div>
<script>
angular.module('MyApp',[])
.controller('welcome', function ($scope) {
});
</script>
when i run the code i got the following error
Error: $ controller: ctrlreg A controller with this name is not registered.
A controller named welcome is not registered.
when i change my application from ('MyApp',[])to ('MyApp'):
MyApp module is not available! You either mistakenly wrote the name of the module or forgot to load it. If registering a module ensures that you specify the dependencies as the second argument.
source
share