"use strict";

angular.module('arethusa.core').directive('debug', function() {
  return {
    restrict: 'A',
    link: function(scope, element, attrs) {
      var obj = scope.$eval(attrs.debug);
      scope.$watch('debug', function(newVal, oldVal) {
        if (newVal) {
          element.show();
        } else {
          element.hide();
        }
      });

      scope.prettyTokens = function() {
        return JSON.stringify(obj, null, 2);
      };
    },
    template: '<pre>{{ prettyTokens() }}</pre>'
  };
});

@@ -163,37 +163,251 @@
  obj
- = scope.$eval(attrs.debug
+;%0A      // We set a watch for the given param in the parent scope,%0A      // so that we can stay in the game even when a reassignment%0A      // happens.%0A      scope.$watch(attrs.debug, function(newVal, oldVal) %7B%0A        obj = newVal;%0A      %7D
 );%0A
+%0A
     

Fix debug directive