How can I clear all the AngularJS $scope and $rootScope values within a single function? -


i need clear $scope values while performing operations.

for eg: if click "signout" button redirect "signin" page, $scope or $rootscope values in session should cleared.

how can achieve this?

you can following:

$rootscope = $rootscope.$new(true); $scope = $scope.$new(true); 

the function $new creating new scope inheriting variables parent. true prevents inheritance.

but not correct approach, because if use thing above, should bootstrap controllers functions manually , recreating tree of scopes.

this might useful though, idea store initialized data stored in variables , then, when assigned copied displayed variables.

the correct solution clear manually every property in each scope on logout event this: logout event:

$rootscope.$emit("logout"); 

catching event:

$rootscope.$on("logout", function(){       $rootscope.mydata = undefined; }); 

or suggested in comments, use service , cleaned.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -