Clear $scope on logout in Angular js

后端 未结 5 1294
深忆病人
深忆病人 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条回答
  •  萌比男神i
    2021-01-19 11:43

    Another approach to manually tracking and cleaning things up would be to broadcast a 'logout' event on the rootScope (or other custom event). Then listen for the event either in your controller or in your service to clean up the data.

    Broadcast:

    $rootScope.broadcast('logout');
    

    Watching for an event (in a service for example):

    $rootScope.on('logout',function(){
      dossiers = [];
    });
    

提交回复
热议问题