bigblind
bigblind

Reputation: 12867

angularjs unknown provider

There are a lot of unknown provider questions on stack overflow, and I've looked at a couple of them so far, but none of them solve my problem. If I find one that does, I'll remove this question.

This is what my code looks like, ExpenseTracker is an angular.module:

ExpenseTracker.run(["$provide", "$q",function($provide, $q){
    console.log("define gapi service")
    window.gapiinit = function($q, $provide){
        var gapiPromise = $q.defer().promise;
        var ROOT = 'https://localhost:1800/_ah/api';
        gapi.client.load('expensetTackerapi', 'v1', function() {
                gapiPromise.resolve(gapi);
},      ROOT);
        $provide.factory("gapi",function(){
            return gapiPromise
        })
    }
}]

the error looks like this:

Uncaught Error: [$injector:unpr] Unknown provider: $provideProvider <- $provide
http://errors.angularjs.org/1.2.7/$injector/unpr?p0=%24provideProvider%20%3C-%20%24provide

Upvotes: 1

Views: 3306

Answers (1)

Daiwei
Daiwei

Reputation: 43556

$provide is a provider, you can only inject $provide in app.config method, not in .run method.

Upvotes: 5

Related Questions