鍍金池/ 問答/HTML5  HTML/ The controller with the name 'NewsContro

The controller with the name 'NewsController' is not registered

index.html里的內(nèi)容

<!DOCTYPE html>
<html>
<head>
    <title>News - SCMS</title>
    <link rel="stylesheet" type="text/css" href="lib/bootstrap/dist/css/bootstrap.css">

</head>
<body ng-app="webapp">
<div class="container" ng-controller="NewsController">
    <h2>News</h2>
    <div class="row" ng-repeat="news in list">
        <div class="col-sm-2">
            <small ng-bind="news.createTime"></small>
        </div>

        <div class="col-sm-10">
        {{news.title}}
        </dir>
    </div>
</div>
<script type="text/javascript" src="lib/angular/angular.js"></script>
<script type="text/javascript" src="lib/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="lib/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="webapp.js"></script>
<script type="text/javascript" src="services/news.client.service.js"></script>
<script type="text/javascript" src="controllers/news.client.controller.js"></script>
</body>
</html>

請(qǐng)問這個(gè)報(bào)錯(cuò)怎么解決

webapp.js 里的內(nèi)容

"use strict";
var webapp = angular.module("webapp",[]);
回答
編輯回答
柒喵

你在html里寫了ng-controller,js里沒有注冊(cè),例如這樣:

webapp.controller("NewsController", ["$scope", function($scope) {
    $scope. news = [];
}])
2018年4月11日 07:13