gpt4 book ai didi

javascript - Angular,无法实例化模块 : Uncaught Error: [$injector:modulerr]

转载 作者:行者123 更新时间:2023-11-28 15:08:48 25 4
gpt4 key购买 nike

我的控制台中不断出现此异常:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=mainApp&p1=Error%3A…at%20g%20(http%3A%2F%2Flocalhost%2Fcinema%2Fjs%2Fangular.min.js%3A39%3A222)

........ angular.min.js:6

和 html 文件:

<!DOCTYPE HTML>
<html ng-app="mainApp">
<head>
<title>This cinema...</title>
<!-- ... other tags -->
<script src="js/angular.min.js"></script>
<script>
var mainApp = angular.module('mainApp', []);

mainApp.config(function ($routeProvider) {

});
</script>
<!-- REST of the HTML body, but no angular used below -->

如果我删除 mainApp.config(func.... ,那么它就可以工作。我不知道如何设置路由。带有路由提供程序的空函数会生成异常?

最佳答案

根据documentation :

$routeProvider requires the ngRoute module to be installed.

因此,您必须在 html 中包含以下脚本:

<script src="js/angular-route.min.js"></script>

并将依赖项添加到您的模块定义中:

var mainApp = angular.module('mainApp', ['ngRoute']);

关于javascript - Angular,无法实例化模块 : Uncaught Error: [$injector:modulerr],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37599587/

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