Search code examples
angularjsangularjs-controller

AngularJS Controller Declaration -- Error: $controller:ctrlreg


I have a basic controller in angularJs named "BasicController". Below is my code (BasicController.js):

(function () {
       var app = angular.module("app", []);
       app.controller("BasicController", function ($scope) {
       alert(2);
       $scope.menus = ["Profile", "About", "Contact"];
    });
}());

But when I run this project below error showing. What actually error says I can't understand. Please someone explain that is the problem actually.

enter image description here


Solution

  • Its not a good that you are following, You need to create a separate file for module and a separate file for controller. And include both of these files in your index file. use this guidelines for best practices. https://github.com/johnpapa/angular-styleguide/tree/master/a1