prash prash - 8 months ago 159
AngularJS Question

Clear $scope on logout in Angular js

In my controller I am storing data as

$scope.$parent.dossierSummaries = data;

but after log out and login the application
retains the same old data.

I am doing this on log out

.success( function( response, status ) {
if ( response.status > 0 ) {
var u = $rootScope.user.username;
$rootScope.user = { username: '', role: 0 };
else {
.error( function( response, status ) {
error(['There was an error logging you out.']);


I don't think there is any effective way to achieve it. Any object (controller, directive,filter or as a matter of fact any js object) can hold reference to another object (in your case user), and one cannot determine easily who all are holding reference.

The reference would only get release if you do it either explicitly or when the object holder the reference is destroyed.

What you can try is


Assuming some object are tracking this specific object the data would be cleared now.