Answer the question
In order to leave comments, you need to log in
Why is the run method throwing an error?
Here is the actual code:
angular.module('user').run(
function($scope,Authentication,$routeParams,$location){
$scope.username =$routeParams.userName;
$scope.currentUserPageSection = $routeParams.section;
Authentication.getUser($scope.username,function(data){
if(data.username){
$scope.pageUser = data;
var status = $scope.user._id === $scope.pageUser._id;
$scope.itsMyPage = status;
$scope.$parent.$parent.itsMyPage = status;
} else {
$location.path('/');
}
},function(){
$location.path('/');
});
});
Uncaught Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope
errors.angularjs.org/1.4.0/$injector/unpr?p0=%24sc...
Answer the question
In order to leave comments, you need to log in
Let's make life a little better. Just forget about scopes. The only place to inject them is in the link function of the directive. nowhere else is it really needed. Not in controllers (use controller as syntax), not in services (you can inject $rootScope for events and only) or anywhere else. Well, yes, you can shove $rootScope into run to set some global things, although again it’s better to just make an ApplicationController.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question