Sandeep Gupta
Sandeep Gupta

Reputation: 37

Angular showing issue ... not getting proper

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

Upvotes: 1

Views: 48

Answers (1)

shaunhusain
shaunhusain

Reputation: 19748

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.

Upvotes: 2

Related Questions