Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS应用程序配置";“未捕获对象”;错误(ngRoute)_Javascript_Html_Angularjs_Url Routing - Fatal编程技术网

Javascript AngularJS应用程序配置";“未捕获对象”;错误(ngRoute)

Javascript AngularJS应用程序配置";“未捕获对象”;错误(ngRoute),javascript,html,angularjs,url-routing,Javascript,Html,Angularjs,Url Routing,我有一个简单的页面: <!doctype html> <html> <head > <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-sc

我有一个简单的页面:

<!doctype html>
<html>
    <head >
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href='bower_components/bootstrap/dist/css/bootstrap.css')>

        <script src='bower_components/jquery/dist/jquery.min.js'></script>
        <script src='bower_components/angular/angular.js'></script>
        <script src='bower_components/bootstrap/dist/js/bootstrap.min.js'></script>
        <script src='js/application.js'></script>

        <title>Bets Application</title>
    </head>
    <body ng-app='betsApp' ng-controller='betsAppCtrl'>
        <h1>BetsApp</h1>
        <ng-view></ng-view>
    </body>
</html>
下面是
login.html

<div>
    <input type='text' ng-model='password' value={{password}}>
</div>
代码永远不会到达以下行:

$locationProvider.html5mode(true);
$routeProvider.when('/login', {templateUrl:'pages/login.html'});
我做错了什么

更新: 以下是我从调试中得到的一些信息:

Line 78, Column 1

Pause On Caught Exceptions

Watch Expressions
Platform: <not available>
data.data: <not available>
Call StackAsync
angular.js:78
(anonymous function)
angular.js:3809
(anonymous function)
angular.js:323
forEach
angular.js:3775
loadModules
angular.js:3715
createInjector
angular.js:1379
doBootstrap
angular.js:1394
bootstrap
angular.js:1307
angularInit
angular.js:21459
(anonymous function)
jquery.js:3073
n.Callbacks.j
jquery.js:3185
n.Callbacks.k.fireWith
jquery.js:3391
n.extend.ready
jquery.js:3407
I
Paused on a JavaScript breakpoint.
Scope Variables
Local
arguments: Arguments[4]
code: "modulerr"
i: 4
message: "[$injector:modulerr] Failed to instantiate module betsApp due to:↵Error: [$injector:unpr] Unknown provider: $routeProvider↵http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider↵    at http://localhost:8000/bower_components/angular/angular.js:78:12↵    at http://localhost:8000/bower_components/angular/angular.js:3705:19↵    at getService (http://localhost:8000/bower_components/angular/angular.js:3832:39)↵    at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:3859:13)↵    at http://localhost:8000/bower_components/angular/angular.js:3788:37↵    at Array.forEach (native)↵    at forEach (http://localhost:8000/bower_components/angular/angular.js:323:11)↵    at loadModules (http://localhost:8000/bower_components/angular/angular.js:3775:5)↵    at createInjector (http://localhost:8000/bower_components/angular/angular.js:3715:11)↵    at doBootstrap (http://localhost:8000/bower_components/angular/angular.js:1379:20)↵http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A78%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20at%20Object.invoke%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3859%3A13)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20%20at%20Array.forEach%20(native)%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A323%3A11)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A1379%3A20)"
prefix: "[$injector:modulerr] "
stringify: function (obj) {
template: "Failed to instantiate module {0} due to:↵{1}"
templateArgs: Arguments[4]
this: undefined
Closure
Closure
Window
Global
Breakpoints
angular.js:78
Error(message);
application.js:4
.html5mode(true);
application.js:5
.when('/login', {templateUrl:'pages/login.html'});
DOM Breakpoints
XHR Breakpoints
Event Listener Breakpoints
Workers
"[$injector:modulerr] Failed to instantiate module betsApp due to:
Error: [$injector:unpr] Unknown provider: $routeProvider
http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider
    at http://localhost:8000/bower_components/angular/angular.js:78:12
    at http://localhost:8000/bower_components/angular/angular.js:3705:19
    at getService (http://localhost:8000/bower_components/angular/angular.js:3832:39)
    at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:3859:13)
    at http://localhost:8000/bower_components/angular/angular.js:3788:37
    at Array.forEach (native)
    at forEach (http://localhost:8000/bower_components/angular/angular.js:323:11)
    at loadModules (http://localhost:8000/bower_components/angular/angular.js:3775:5)
    at createInjector (http://localhost:8000/bower_components/angular/angular.js:3715:11)
    at doBootstrap (http://localhost:8000/bower_components/angular/angular.js:1379:20)
http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A78%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20at%20Object.invoke%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3859%3A13)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20%20at%20Array.forEach%20(native)%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A323%3A11)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A1379%3A20)"
第78行第1列
暂停捕获的异常
观察表情
站台:
数据。数据:
调用StackAsync
见附件。js:78
(匿名函数)
www.js:3809
(匿名函数)
www.js:323
弗雷奇
www.js:3775
加载模块
www.js:3715
创建注入器
见附件js:1379
多布托陷阱
js:1394
独自创立
www.js:1307
角闪石
js:21459
(匿名函数)
jquery.js:3073
n、 回调
jquery.js:3185
n、 Callbacks.k.fireWith
jquery.js:3391
n、 准备好了吗
jquery.js:3407
我
在JavaScript断点上暂停。
范围变量
地方的
论点:论点[4]
代码:“moduler”
i:4
消息:“[$injector:modulerr]未能实例化模块应用程序,原因是:↵错误:[$injector:unpr]未知提供程序:$routeProvider↵http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider↵    在http://localhost:8000/bower_components/angular/angular.js:78:12↵    在http://localhost:8000/bower_components/angular/angular.js:3705:19↵    在getService(http://localhost:8000/bower_components/angular/angular.js:3832:39)↵    在Object.invoke(http://localhost:8000/bower_components/angular/angular.js:3859:13)↵    在http://localhost:8000/bower_components/angular/angular.js:3788:37↵    at Array.forEach(本机)↵    在弗雷赫(http://localhost:8000/bower_components/angular/angular.js:323:11)↵    在加载模块时(http://localhost:8000/bower_components/angular/angular.js:3775:5)↵    在createInjector(http://localhost:8000/bower_components/angular/angular.js:3715:11)↵    在多布茨特拉普(http://localhost:8000/bower_components/angular/angular.js:1379:20)↵http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20未知%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20at%20http%3A%2F%2F%2Flocalhost%3A8000%2Fbower%2fr\u组件%2Fangular%2f3fjs%12%20%20%20%20%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20%20at%20对象。调用%20(http%3A%2Flocalhost%2Flocalhost%2f8000%2Fbower%2Fangular%2Fangular%2fAngu%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20at%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular.js%3A323%3A11)%0A%20%20%20%20%20%20%20at%20at%20forEach%20%20%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20%20at%20createInjector%20(http%3A%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20%20%20doBootstrap%20(http%3A%2Flocalhost%2f2fLocalHost%2Fangular%2Fbower%2Fangular%2Fangular%2Fangular
前缀:“[$injector:modulerr]”
字符串化:功能(obj){
模板:“未能实例化模块{0},原因是:↵{1}"
templateArgs:参数[4]
这个:未定义
关闭
关闭
窗口
全球的
断点
见附件。js:78
错误(消息);
application.js:4
.HTML5模式(正确);
application.js:5
.when('/login',{templateUrl:'pages/login.html'});
DOM断点
XHR断点
事件侦听器断点
工人
“[$injector:modulerr]未能实例化模块应用程序,原因是:
错误:[$injector:unpr]未知提供程序:$routeProvider
http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider
在http://localhost:8000/bower_components/angular/angular.js:78:12
在http://localhost:8000/bower_components/angular/angular.js:3705:19
在getService(http://localhost:8000/bower_components/angular/angular.js:3832:39)
在Object.invoke(http://localhost:8000/bower_components/angular/angular.js:3859:13)
在http://localhost:8000/bower_components/angular/angular.js:3788:37
at Array.forEach(本机)
在弗雷赫(http://localhost:8000/bower_components/angular/angular.js:323:11)
在加载模块时(http://localhost:8000/bower_components/angular/angular.js:3775:5)
在createInjector(http://localhost:8000/bower_components/angular/angular.js:3715:11)
在多布茨特拉普(http://localhost:8000/bower_components/angular/angular.js:1379:20)
http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20未知%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20at%20http%3A%2F%2F%2Flocalhost%3A8000%2Fbower%2fr\u组件%2Fangular%2f3fjs%12%20%20%20%20%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20%20at%20对象。调用%20(http%3A%2Flocalhost%2Flocalhost%2f8000%2Fbower%2Fangular%2Fangular%2fAngu%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20at%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular.js%3A323%3A11)%0A%20%20%20%20%20%20%20at%20at%20forEach%20%20%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20%20at%20createInjector%20(http%3A%2Flocalhost%3A8000%2Fbower_组件%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20%20%20doBootstrap%20(http%3A%2Flocalhost%2f2fLocalHost%2Fangular%2Fbower%2Fangular%2Fangular%2Fangular

您必须添加角路由模块!

在v1.2+中,是一个单独的模块,应该是l
$locationProvider.html5mode(true);
$routeProvider.when('/login', {templateUrl:'pages/login.html'});
Line 78, Column 1

Pause On Caught Exceptions

Watch Expressions
Platform: <not available>
data.data: <not available>
Call StackAsync
angular.js:78
(anonymous function)
angular.js:3809
(anonymous function)
angular.js:323
forEach
angular.js:3775
loadModules
angular.js:3715
createInjector
angular.js:1379
doBootstrap
angular.js:1394
bootstrap
angular.js:1307
angularInit
angular.js:21459
(anonymous function)
jquery.js:3073
n.Callbacks.j
jquery.js:3185
n.Callbacks.k.fireWith
jquery.js:3391
n.extend.ready
jquery.js:3407
I
Paused on a JavaScript breakpoint.
Scope Variables
Local
arguments: Arguments[4]
code: "modulerr"
i: 4
message: "[$injector:modulerr] Failed to instantiate module betsApp due to:↵Error: [$injector:unpr] Unknown provider: $routeProvider↵http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider↵    at http://localhost:8000/bower_components/angular/angular.js:78:12↵    at http://localhost:8000/bower_components/angular/angular.js:3705:19↵    at getService (http://localhost:8000/bower_components/angular/angular.js:3832:39)↵    at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:3859:13)↵    at http://localhost:8000/bower_components/angular/angular.js:3788:37↵    at Array.forEach (native)↵    at forEach (http://localhost:8000/bower_components/angular/angular.js:323:11)↵    at loadModules (http://localhost:8000/bower_components/angular/angular.js:3775:5)↵    at createInjector (http://localhost:8000/bower_components/angular/angular.js:3715:11)↵    at doBootstrap (http://localhost:8000/bower_components/angular/angular.js:1379:20)↵http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A78%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20at%20Object.invoke%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3859%3A13)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20%20at%20Array.forEach%20(native)%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A323%3A11)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A1379%3A20)"
prefix: "[$injector:modulerr] "
stringify: function (obj) {
template: "Failed to instantiate module {0} due to:↵{1}"
templateArgs: Arguments[4]
this: undefined
Closure
Closure
Window
Global
Breakpoints
angular.js:78
Error(message);
application.js:4
.html5mode(true);
application.js:5
.when('/login', {templateUrl:'pages/login.html'});
DOM Breakpoints
XHR Breakpoints
Event Listener Breakpoints
Workers
"[$injector:modulerr] Failed to instantiate module betsApp due to:
Error: [$injector:unpr] Unknown provider: $routeProvider
http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24routeProvider
    at http://localhost:8000/bower_components/angular/angular.js:78:12
    at http://localhost:8000/bower_components/angular/angular.js:3705:19
    at getService (http://localhost:8000/bower_components/angular/angular.js:3832:39)
    at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:3859:13)
    at http://localhost:8000/bower_components/angular/angular.js:3788:37
    at Array.forEach (native)
    at forEach (http://localhost:8000/bower_components/angular/angular.js:323:11)
    at loadModules (http://localhost:8000/bower_components/angular/angular.js:3775:5)
    at createInjector (http://localhost:8000/bower_components/angular/angular.js:3715:11)
    at doBootstrap (http://localhost:8000/bower_components/angular/angular.js:1379:20)
http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=betsApp&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24routeProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.16%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A78%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3705%3A19%0A%20%20%20%20at%20getService%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3832%3A39)%0A%20%20%20%20at%20Object.invoke%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3859%3A13)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3788%3A37%0A%20%20%20%20at%20Array.forEach%20(native)%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A323%3A11)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3775%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A3715%3A11)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fbower_components%2Fangular%2Fangular.js%3A1379%3A20)"
<script src='bower_components/angular/angular.js'></script>
<script src='bower_components/angular/angular-route.js'></script>

var betsApp = angular.module('betsApp', ['ngRoute']);
bower install angular-route
var betsApp = angular.module('betsApp', ['ngRoute']);
angular.module('foo', ['ngRoute']);

<html ng-app="foo">