我对此感到有点生气。为什么这个脚本在SE中运行但在JSFiddle ???
中不起作用
var myApp = angular.module('myApp', ['myControllers']);
var myControllers = angular.module('myControllers', []);
myControllers
.controller('MyController', ['$scope', function ($scope) {
$scope.petameters = 10;
$scope.lightyears = $scope.petameters / 9.460730472580800;
$scope.parsecs = $scope.lightyears / 3.2616;
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="MyController">
Petameters:<input type="text" ng-model="petameters"><br/>
Light years:<input type="text" ng-model="lightyears"><br/>
Parsecs:<input type="text" ng-model="parsecs"><br/>
</div>
</body>
JSFiddle:https://jsfiddle.net/dimskraft/wr7kvsy9/5/
代码是复制粘贴的。在JSFiddle版本中,它不会在单元格中显示任何值。
它还会抛出一个异常Uncaught Error: [$injector:modulerr]
,其中包含未设置占位符的消息Failed to instantiate module {0} due to:\n{1}"
...