gpt4 book ai didi

javascript - AngularJS [$注入(inject)器 :modulerr] no mod 'testApp' is not available

转载 作者:行者123 更新时间:2023-11-30 00:19:49 24 4
gpt4 key购买 nike

这是我的 html 文件:

<!DOCTYPE html>
<html ng-app="testApp">

<head>
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.js"></script>
</head>

<body>
<div ng-controller="TileController" class="finder-info-square">
// code....
</div>
</body>
</html>

这是我的 Javascript 文件:

(function(){
var app = angular.module("testApp", []);

var TileController = function($scope){
// do stuff....
};

app.controller("TileController", ["$scope", TileController]);
})();

这是我不断收到的错误...

Uncaught Error: [$injector:modulerr] Failed to instantiate module testApp due to: Error: [$injector:nomod] Module 'testApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

有人知道为什么会出现这个错误吗?我正在尝试创建自己的 testApp 模块,但由于某种原因,它在创建模块时一直抛出此错误。

最佳答案

您需要包含您的 javascript 文件以及 Angular 库

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.js"></script>
<script src="path/to/myscript.js"></script>

关于javascript - AngularJS [$注入(inject)器 :modulerr] no mod 'testApp' is not available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33598657/

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