Javascript 角度,无法实例化模块:未捕获错误:[$injector:moduler]

Javascript 角度,无法实例化模块:未捕获错误:[$injector:moduler],javascript,angularjs,exception,Javascript,Angularjs,Exception,我的控制台中不断出现此异常: 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文件: <!

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

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 -->

这家电影院。。。
var mainApp=angular.module('mainApp',[]);
mainApp.config(函数($routeProvider){
});
如果我删除了
mainApp.config(func…
,那么它正在工作。我不知道如何设置路由。带有路由提供程序的空函数会生成异常?

根据:

$routeProvider需要安装
ngRoute
模块

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

<script src="js/angular-route.min.js"></script>
根据报告:

$routeProvider需要安装
ngRoute
模块

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

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

$routeProvider
需要单独的angular模块
ngRoute
。下载angular-route.js,将其添加到页面中,并将其注入angular.module方法中

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

mainApp.config(function ($routeProvider) {

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

这家电影院。。。
var mainApp=angular.module('mainApp',['ngRoute']);
mainApp.config(函数($routeProvider){
});

$routeProvider
需要一个单独的angular模块
ngRoute
。下载angular-route.js,将其添加到页面中,并将其插入angular.module方法中

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

mainApp.config(function ($routeProvider) {

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

这家电影院。。。
var mainApp=angular.module('mainApp',['ngRoute']);
mainApp.config(函数($routeProvider){
});

您可以尝试在不使用
ngRoute
模块的情况下使用
$routeProvider

请参阅文档:

试试这个:

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

mainApp.config(function ($routeProvider) {

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

这家电影院。。。
var mainApp=angular.module('mainApp',['ngRoute']);
mainApp.config(函数($routeProvider){
});

您可以尝试在不使用
ngRoute
模块的情况下使用
$routeProvider

请参阅文档:

试试这个:

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

mainApp.config(function ($routeProvider) {

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

这家电影院。。。
var mainApp=angular.module('mainApp',['ngRoute']);
mainApp.config(函数($routeProvider){
});

您没有包括
angular routing.js
脚本参考,也没有将
ngRoute
注入
mainApp
模块。您没有包括
angular routing.js
脚本参考,也没有将
ngRoute
注入
mainApp
模块。我已经包括了angular route js文件,现在可以工作了。如果我将自定义javascript代码移到另一个js文件中,并将其包含在html文件和“js/main.js”中,问题仍然存在文件包含我原始帖子中的代码。@ZbarceaChristian,别忘了在您的模块定义中指定对“ngRoute”的依赖关系。这里的工作演示我已经包含了angular route js文件,现在它正在工作。如果我将自定义javascript代码移动到另一个js文件并包含在html文件中,问题仍然存在:“js/main.js”文件包含我的原始帖子中的代码。@ZbarceaChristian,别忘了在模块定义中指定对“ngRoute”的依赖关系。下面是工作演示