gpt4 book ai didi

javascript - 获取错误 "Failed to instantiate module {0} due to:\n{1}"

转载 作者:行者123 更新时间:2023-11-30 16:22:22 26 4
gpt4 key购买 nike

我有点生气了。为什么这个脚本在 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}" with未设置占位符...

最佳答案

jsfiddle 设置错误。 onLoad 事件执行的脚本

enter image description here

例如,您应该将其更改为 "no wrap - in <head>"

enter image description here

一切正常

JS fiddle

关于javascript - 获取错误 "Failed to instantiate module {0} due to:\n{1}",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34559541/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com