Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Erik Myers
Erik Myers
11,582 Points

Building with AngularJS and APIs Workshop Bug

I was following the workshop and everything was going smoothly until I reached the 27:20 mark, where I input this line of code:

app.config(function($routeProvider) {
    $routeProvider.when('/:list', {controller:"ShotsListCtrl", templateURL:"partials/shots_list.html"});
});

I am using the latest versions of Bootstrap and Angular, not the ones supplied. This is the error the console shows:

Uncaught Error: [$injector:modulerr] Failed to instantiate module dabbble due to: Error: [$injector:unpr] Unknown provider: $routeProvider http://errors.angularjs.org/1.3.0-rc.0/$injector/unpr?p0=%24routeProvider at http://dabbble2.dev/js/angular.js:80:12 at http://dabbble2.dev/js/angular.js:3925:19 at getService (http://dabbble2.dev/js/angular.js:4058:39) at Object.invoke (http://dabbble2.dev/js/angular.js:4090:13) at runInvokeQueue (http://dabbble2.dev/js/angular.js:4005:35) at http://dabbble2.dev/js/angular.js:4014:11 at forEach (http://dabbble2.dev/js/angular.js:332:20) at loadModules (http://dabbble2.dev/js/angular.js:3995:5) at createInjector (http://dabbble2.dev/js/angular.js:3935:11) at doBootstrap (http://dabbble2.dev/js/angular.js:1496:20) http://errors.angularjs.org/1.3.0-rc.0/$injector/modulerr?p0=dabbble&p1=Err…t%20doBootstrap%20(http%3A%2F%2Fdabbble2.dev%2Fjs%2Fangular.js%3A1496%3A20)

It has something to do with $routeProvider. After some research I found out that route went through some changes in the later versions of Angular. Could this be the source of my problem?

2 Answers

Yup, ngRoute is now a separate module that needs to be included in your project. Basically you need to get the angular-route.js file and add it to your project:

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

For more info, check out the documentation. It has a section on installing the module.

Erik Myers
Erik Myers
11,582 Points

Awesome, thanks a lot Dino!