A controller with this name is not registered ‘MonsterController’

how to A controller with this name is not registered ‘MonsterController’

I’m new in AngularJS.I want to learn services but i received an error message that MonsterController is not registered.I already created the controller inside app.js file and checked spell but still got this problem.I don’t know with part did i do wrong.I hope you guys can help me solve this problem.Thank you in advance.

ERROR MESSAGE

The controller with the name ‘MonsterController’ is not registered.

index.html

<!DOCTYPE html>
<html ng-app="training">
  <head>
    <link rel="stylesheet" type="text/css" href="../bootstrap.min.css" />
    <script type="text/javascript" src="../angular.min.js"></script>
    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="formapp.js"></script>

        <link rel="stylesheet" href="../style.css" />
  </head>

  <body>

    <div ng-controller="UserController as usersCtrl">
    <h3>User Information</h3>
    <div ng-repeat="user in usersCtrl.mUsers">
        <p><ul>
            <li>{{user.name}}</li>
            <li>{{user.age}}</li>
            <li>{{user.occupation}}</li>
        </ul></p>
    </div> 
    <form-Directive></form-Directive>
    </div>

    <div ng-controller="MonsterController as monsterCtrl">
    <h3>Monster Information</h3>
    <p><ul>
      <li> {{monsterCtrl.name}}</li>
    </ul></p>
    </div>
  </body>

</html>

app.js

(function(){


    var app = angular.module('training',['form']);

    app.controller('MonsterController',['$http',function($http){
        var mob = this;
        mob = [];

        $http.get('/data.json').success(function(data){
            mob = data;
        });

    }]);

    app.controller('UserController',function(){
        this.mUsers = users;
    });

    var users = [{
        name:"michael",
        age:"27",
        occupation:"business"
    },{
        name:"john",
        age:"25",
        occupation:"police"
    }];

})();

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.