Angularjs - Unknown Provider

Asked

Viewed 2,187 times

0

I am trying to create a Service in Angularjs but the error is occurring: Error: [$injector:unpr] Unknown Provider: $scopeProvider <- $Scope <- Orderservice

I tried everything to fix, I stopped Stackoverflow in English and tested several solutions and unsuccessfully.

Code http://pastebin.com/xBiDiSv7

Error that appears on console: Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- OrderService http://errors.angularjs.org/1.3.15/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20OrderService at REGEX_STRING_REGEXP (angular.min.js:65) at angular.min.js:4060 at Object.getService [as get] (angular.min.js:4214) at angular.min.js:4065 at getService (angular.min.js:4214) at invoke (angular.min.js:4244) at Object.instantiate (angular.min.js:4261) at Object.<anonymous> (angular.min.js:4119) at Object.invoke (angular.min.js:4253) at Object.enforcedReturnValue [as $get] (angular.min.js:4103)

1 answer

1


The error points to the lack of reference to the module $scope. Check that the reference is being correctly injected.

  • In the controller and in the service I put the reference.

  • @adelmo00 On which line of the code Voc6e placed in Pastebin is the error occurring?

  • Line 7, if I remove Orderservice and the call inside init(), it works fine.

  • @adelmo00 now I see the problem. Services cannot directly receive injection of $scope.

  • 1

    I took the $Scope and left only the $http and $Location and it worked. Thank you very much. I will read the documentation better to stop catching some.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.