Reputation: 16513
When I try to add $scope
in the below give code I am getting error
angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers'])
.run(['$window', '$location', '$rootScope', '$scope', function ($window, $location, $rootScope, $scope) {}]);
Error:
Uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.2.26/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope
Upvotes: 0
Views: 136
Reputation: 41387
you can't inject $scope
to the run component. alternatively, you have to use the $rootScope
.Because top-level scope is rootScope and all child scope is inherit from it
angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers'])
.run(['$window', '$location', '$rootScope', function ($window, $location, $rootScope) {
}]);
Upvotes: 1