revolunet / angular-google-analytics

Google Analytics tracking for your AngularJS apps
MIT License
652 stars 172 forks source link

Error: [$injector:strictdi] function(AnalyticsProvider) is not using explicit annotation and cannot be invoked in strict mode #180

Closed lrkwz closed 7 years ago

lrkwz commented 7 years ago

I have an angularjs application where app.module.js is:

(function() {
    'use strict';

    angular
        .module('myApp', [
           // ...
            'angular-google-analytics'
        ])
        .config(function (AnalyticsProvider) {
               // Add configuration code as desired
               AnalyticsProvider.setAccount('UU-XXXXXXX-X');  //UU-XXXXXXX-X should be your tracking code
            })
        .run(run);

    run.$inject = ['stateHandler', 'translationHandler', 'Analytics'];

    function run(stateHandler, translationHandler, Analytics) {
        stateHandler.initialize();
        translationHandler.initialize();        
    }
})();

I cannot understand how to invoke .config() correctlry

justinsa commented 7 years ago

@lrkwz Please read: https://docs.angularjs.org/error/$injector/strictdi

This issue is not with angular-google-analytics library but how you have written the code.

You either need to use the annotated method call or the $inject function to declare dependencies.

As in:

config.$inject('AnalyticsProvider');

or

.config(['AnalyticsProvider', function (AnalyticsProvider) { ... }]);
lrkwz commented 7 years ago

Ok thank you, I've fixed the configuration and posted my question here http://stackoverflow.com/questions/40612321/start-tracking-angular-google-analytics sorry for bothering here.

justinsa commented 7 years ago

@lrkwz Posting your question on StackOverflow probably won't get you a response since you are asking a question about how angular-google-analytics configuration and setup works.

Have you thoroughly gone through the README and tried following the quick start?

lrkwz commented 7 years ago

yes ... as you can see I did not understand (probabily because I'm an angularjs newbie), but I'm not the only one http://stackoverflow.com/questions/40192085/angular-google-analytics-integration

=> Luca http://stackexchange.com/users/239746

2016-11-15 16:49 GMT+01:00 Justin Saunders notifications@github.com:

@lrkwz https://github.com/lrkwz Posting your question on StackOverflow probably won't get you a response since you are asking a question about how angular-google-analytics configuration and setup works.

Have you thoroughly gone through the README and tried following the quick start?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/revolunet/angular-google-analytics/issues/180#issuecomment-260678217, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-mGDKBLa1HDytsm8H_fHvWSOlLPm_bks5q-dR-gaJpZM4Kx0b_ .