Angular showing issue … not getting proper

Issue

I am new to angular JS. Please take a look. This is my app.js file

angular.module("CrudDemoApp",["CrudDemoApp.controllers","ngRoute"]);

this is my controllers.js file

angular.module("CrudDemoApp.controllers", []);
controllers("MainController", function ($scope)
{
    $scope.message = "Main Controller";  
});

this is the my body part

<body ng-app="CrudDemoApp">
<div ng-controller="MainController">
{{message}}
</div>
</body>

firstly it is saying “Uncaught ReferenceError: controllers is not defined
at then it is saying
Error: [ng:areq] http://errors.angularjs.org/1.5.6/ng/areq?p0=MainController&p1=not%20a%20function%2C%20got%20undefined

Solution

angular.module("CrudDemoApp.controllers", []) //remove semicolon here adding the controller to this module
  .controller("MainController", function ($scope) // dot before controller, remove "s"
  {
      $scope.message = "Main Controller";  
  });

notice the dot and lack of pluralization on controller

You should have probably seen some other errors before the ones you mentioned always work from the first one down sometimes 1 error causes the next.

Answered By – shaunhusain

Answer Checked By – Gilberto Lyons (AngularFixing Admin)

Leave a Reply

Your email address will not be published.