gpt4 book ai didi

javascript - Angular .js :38 Uncaught Error: [$injector:modulerr]

转载 作者:行者123 更新时间:2023-11-28 04:28:56 27 4
gpt4 key购买 nike

我一直收到这个错误:

angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.4/$injector/modulerr?p0=sport1Feed&p1=Error…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.4%2Fangular.min.js%3A22%3A179)
at angular.js:38
at angular.js:4920
at q (angular.js:403)
at g (angular.js:4880)
at eb (angular.js:4802)
at c (angular.js:1914)
at Sc (angular.js:1935)
at ue (angular.js:1820)
at angular.js:33367
at HTMLDocument.b (angular.js:3431)

我的应用程序是用 html 定义和调用的,就像我的 Controller 一样。我在这里做错了什么?

应用程序.js:

var app = angular.module('testApp', ['ngAnimate', 'ngSanitize', 'ui.bootstrap','ui.router']);

控制.js:

app.controller('feedCtrl', function($scope, $http) {
$http.get('https://api.myjson.com/bins/13vg19').then(function(res) {
$scope.res = res.data;
console.log($scope.res);
});
});

html:

<!DOCTYPE html>
<html ng-app="testApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My AngularJS App</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="app.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="./components/app/app.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.3/angular-ui-router.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.6.4/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/x2js/1.2.0/xml2json.js"></script>
<script src="./components/controller/ctrl.js"></script>
</head>
<body>

<div data-ng-controller="feedCtrl">

</div>

</body>
</html>

这里的错误到底是什么?我尝试将 ng-app 放在 body 标签中,结果相同。可以看到,app.js是在angular库之后调用的。

谢谢。

编辑:我刚刚在控制台中注意到,在网络下,对 https://api.myjson.com/bins/13vg19 的请求根本没有被调用。

最佳答案

加载所有依赖引用后加载app.js,你的顺序应该是

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.3/angular-ui-router.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.6.4/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/x2js/1.2.0/xml2json.js"></script>
<script src="./components/app/app.js"></script>
<script src="./components/controller/ctrl.js"></script>

关于javascript - Angular .js :38 Uncaught Error: [$injector:modulerr],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43981858/

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