Why not able to inject '$scope' service in the service layer? If i add $scope inside the array, it brings the injection error.
app.service('LoginService', [ '$log', '$http', '$rootScope', '$scope', '$location', function($log, $http, $rootScope, $scope, $location) {
Simply put, $scope is the scope of a controller which is bound to a view.
Services are singleton objects which contain or encapsulate reusable pieces of logic/functionality/code. Hence logically they do not have a scope at all. One can use variables in the services to set values/data and use or share it elsewhere.
Which is why its not allowed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With