Angularjs 正在获取未捕获错误:[$injector:unpr]当注入$scope时

Angularjs 正在获取未捕获错误:[$injector:unpr]当注入$scope时,angularjs,Angularjs,当我试图在下面的代码中添加$scope时,我得到了一个错误 angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers']) .run(['$window', '$location', '$rootScope', '$scope', function ($window, $location, $rootScope, $scope) {}]); 错误: 无法将$scope注入运行组件。或者,您必须使用$rootS

当我试图在下面的代码中添加$scope时,我得到了一个错误

angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers'])
  .run(['$window', '$location', '$rootScope', '$scope', function ($window, $location, $rootScope, $scope) {}]);
错误:

无法将$scope注入运行组件。或者,您必须使用$rootScope.com,因为顶级作用域是rootScope,而所有子作用域都是从它继承的

angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers'])
  .run(['$window', '$location', '$rootScope', function ($window, $location, $rootScope) {

}]);
angular.module('starter', ['ngRoute', 'ngAnimate', 'myApp.controllers'])
  .run(['$window', '$location', '$rootScope', function ($window, $location, $rootScope) {

}]);