mgonto / angularytics

The solution to tracking page views and events in a SPA with AngularJS
MIT License
630 stars 70 forks source link

.run-module-injection not working #24

Open kristoffernolgren opened 10 years ago

kristoffernolgren commented 10 years ago

The most simplistic code I can use to test this is this:

angular.module('weather', ['ngRoute', 'angularytics']). config(function($routeProvider, AngularyticsProvider){

AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);

}). controller...

working

but this:

angular.module('weather', ['ngRoute', 'angularytics']). config(function($routeProvider, AngularyticsProvider){

AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);

}).run(function(Angularytics){ Angularytics.init(); }). controller....

not working. I get the following error: Uncaught Error: [$injector:unpr] Unknown provider: AngularyticsConsoleHandlerProvider <- AngularyticsConsoleHandler <- Angularytics

thomasplevy commented 10 years ago

I was encountering this issue until I realized it was because I wasn't loading the consoleHandler.js file in the src directory of the repo, once I loaded that file the module began functioning.

I then realized that I really don't need the consoleHandler.js file (because it just logs stuff to the console for debug purposes) so I removed it from the setEventHandlers array and stopped loading the file.

Hope that helps!