6

I am making my first Angular app and I'm trying to figure out how to use the errors displayed in the console to figure out where in my code things are breaking. Here is an example console error:

Error: [$injector:unpr] Unknown provider: HomeProvider <- Home
http://errors.angularjs.org/1.2.5/$injector/unpr?p0=HomeProvider%20%3C-%20Home
    at http://recipe-app/lib/angular/angular.js:78:12
    at http://recipe-app/lib/angular/angular.js:3519:19
    at Object.getService [as get] (http://recipe-app/lib/angular/angular.js:3646:39)
    at http://recipe-app/lib/angular/angular.js:3524:45
    at getService (http://recipe-app/lib/angular/angular.js:3646:39)
    at invoke (http://recipe-app/lib/angular/angular.js:3668:13)
    at Object.instantiate (http://recipe-app/lib/angular/angular.js:3689:23)
    at http://recipe-app/lib/angular/angular.js:6714:28
    at link (http://recipe-app/lib/angular/angular-route.js:897:26)
    at nodeLinkFn (http://recipe-app/lib/angular/angular.js:6168:13) <div ng-view="" class="full-screen ng-scope"> 

See how all the line numbers refer to lines within the angular.js file and not my source files? That leaves me guessing where my error is.

Note: I'm not looking for a solution to this specific error. I'm trying to figure out in general how to find the source of these errors using Angular.

I've installed Batarang already, but thats not showing me this error at all. Also, other SO answers show you how to manually log error information to the console by inserting code in specific places, but that assumes I have a general idea where it's coming from.

Thanks in advance, sorry for being dim.

2
  • Did you ever "figure out in general how to find the source of these errors using Angular."? Commented Mar 5, 2015 at 18:35
  • Hi Jeff, to be honest, I haven't touched angular for about a year, so I won't be much help. But it looks like I accepted the answer below, so maybe that's the solution. Commented Mar 6, 2015 at 5:52

1 Answer 1

4

This happens when any of your services are not defined. So check if all your services are included to index.html. In your case I see that your Home service is not found.

Sign up to request clarification or add additional context in comments.

1 Comment

Ahh yes, that did it. I actually don't have a service named Home but had copied and pasted the controller for Home from a controller that did have one. It was looking for a service that I didn't have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.