AngularJS: Uncaught Error: [$injector:modulerr] with jsfiddle

AngularJS: Uncaught Error: [$injector:modulerr] with jsfiddle

为什么这个简单的脚本会在控制台中抛出未捕获的错误:[$injector:modulerr]?

<script>
angular.module('HelloWorldApp', []);
angular.module('HelloWorldApp').controller('HelloWorldController', function($scope) {
       $scope.greeting = "Hello World";
});
</script>
<div ng-app="HelloWorldApp">
    <div ng-controller="HelloWorldController">
        <h1>{{greeting}}</h1>
    </div>
</div>

https://jsfiddle.net/Lccfcrwm/

您必须在 HTML 中添加:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

这是一个简单的例子:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
    <p>{{greeting}}</p>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.greeting = "Hello";

});
</script>



</body>
</html>

让你的 fiddle 工作,实际上在 javascript 窗格中你需要 select angular 1.x 版本,它会开始工作

这里是fiddle:https://jsfiddle.net/2xxf507e/

 angular.module('HelloWorldApp', []);
 angular.module('HelloWorldApp').controller('HelloWorldController', function($scope) {
       $scope.greeting = "Hello World";
});

和设置图片