错误:[$ controller:ctrlreg]未注册名为“quizController”的控制器

时间:2018-02-08 03:20:58

标签: angularjs ng-controller

我收到了错误:

  

[$ controller:ctrlreg]名称为“quizController”的控制器未注册。

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 个答案:

答案 0 :(得分:0)

相应地更改index.html。另外,请确保已对导入进行排序。

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