AngularJS application config “Uncaught object” error (ngRoute)

穿精又带淫゛_ 提交于 2019-11-28 12:12:46

In v1.2+, ngRoute is a separate module and should be loaded independently (and also declared as a dependency of your main module).

<script src='bower_components/angular/angular.js'></script>
<script src='bower_components/angular/angular-route.js'></script>

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

If you are using bower, you can download the ngRoute module with the following command:
bower install angular-route

RouteProvider is now in a separate module from the core Angular distribution. See https://docs.angularjs.org/api/ngRoute.

Since it looks like you're using bower, I would do a

bower install angular-route

which will download the requisite .js file and place it in the bower_components directory. Modify the HTML to include this script. Then, the first line line in your application.js file should read:

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

Be sure your Module and ng-app are equals

angular.module('foo', ['ngRoute']);

<html ng-app="foo">

You have to add angular-route module!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!