Error: [$controller:ctrlreg] The controller with the name 'quizController' is not registered

782 Views Asked by At

I'm getting Error:

[$controller:ctrlreg] The controller with the name 'quizController' is not registered.

quizController.js:

angular.module("quizApp",[])
    .controller("quizController", function($scope) {
        $scope.message = "Hello World";
    });

index.html:

<!DOCTYPE html>
<html lang="en" ng-app="quizApp">
<head>
    <meta charset="UTF-8">
    <title>Quiz</title>
    <link rel="stylesheet" href="src/style.css">
</head>
<body ng-controller="quizController">
<!-- <h1>hello world please work!</h1>  -->
{{message}}
  <script src="src/libs.js"></script>
  <script src="src/scripts.js"></script>
  <script src="app.js"></script>
</body>
</html>
1

There are 1 best solutions below

5
Ivas On

Change your index.html accordingly. Also, make sure that you have your imports sorted.

    <div ng-app="quizApp">
      <h1>Controllers</h1>
      <div ng-controller="quizController">
        <p>{{ message }}</p>
      </div>
    </div>
<script src="quizController.js"></script>