Clear $scope on logout in Angular js

后端 未结 5 1256
深忆病人
深忆病人 2021-01-19 10:59

In my controller I am storing data as $scope.$parent.dossierSummaries = data; but after log out and login the application $scope.$parent.dossierSummaries<

5条回答
  •  无人共我
    2021-01-19 11:42

    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

    $rootScope.user.username='';
    $rootScope.role=0; 
    

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

提交回复
热议问题