Angular,没有模块的控制器,无法破译错误

Angular, controller without a module, unable to decipher the error

See the image for the problem
angular.controller('myController', function ($scope) { var reg = { firstName: 'Aaa', lastName: 'Sss', }; $scope.reg = reg; }); 这是我的 control.js 文件

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Script/angular.min.js"></script>
<script src="Script/ControllerOnly.js"></script>
</head>
<body>
<div ng-controller="myController">
    FirstName <input type="text" ng-model="reg.firstName" />
     <br />    
 LastName<input type="text" ng-model="reg.lastName" />
    <br />
    <br />
    {{reg.firstName}}
    <br />
    {{reg.lastName}}
    </div>
</body>
</html>

这是我的 html 文件。

未获得输出且无法破译错误。 任何帮助将不胜感激并提前致谢..

到目前为止,您还没有初始化任何 angular 应用程序。在你的 control.js

myApp=angular.module('myApp', []); myApp.controller('myController', function ($scope) { 在你的 HTML

<body ng-app="myApp"> 这应该可以解决它.. :)

您在 html 中遗漏了 ng-app

请查看此工作 fiddle: https://jsfiddle.net/r6ydu0p8/