How to retain scope value, when scope is destroyed between link and controller
<p>I have a scenario, where there are two tabs on a page: Is there a way to retain the values of <code>x</code>  ?</p>

<p>I have tried with <code>$rootscope.$on</code>, and it worked. Is there any other way to implement it?  </p>

<pre><code>angular.module('x', []).directive('y', function() {

      return: {
        restrict: 'E',
        replace: true,
        templateUrl: '',
        scope: {},
        controller: function($scope) {
          console.log($scope.test); // the value is x when i am on the      //same tab, the value is undefined when i  switch the tab 
        },
        link: function(scope) {
          scope.test = 'x';
        }

      });
</code></pre>