“Uncaught Error: [$injector:unpr]” with angular after deployment

后端 未结 7 1110
灰色年华
灰色年华 2020-11-30 21:45

I have a fairly simple Angular application that runs just fine on my dev machine, but is failing with this error message (in the browser console) after I deploy it:

相关标签:
7条回答
  • 2020-11-30 22:27

    I had the same problem but the issue was a different one, I was trying to create a service and pass $scope to it as a parameter.
    That's another way to get this error as the documentation of that link says:

    Attempting to inject a scope object into anything that's not a controller or a directive, for example a service, will also throw an Unknown provider: $scopeProvider <- $scope error. This might happen if one mistakenly registers a controller as a service, ex.:

    angular.module('myModule', [])
           .service('MyController', ['$scope', function($scope) {
            // This controller throws an unknown provider error because
            // a scope object cannot be injected into a service.
    }]);
    
    0 讨论(0)
提交回复
热议问题