diff --git a/js/directives/jsonTree.js b/js/directives/jsonTree.js
new file mode 100644
index 0000000..f7bf857
--- /dev/null
+++ b/js/directives/jsonTree.js
@@ -0,0 +1,47 @@
+// JSON tree
+panelApp.directive('batJsonTree', function($compile) {
+ return {
+ restrict: 'E',
+ terminal: true,
+ scope: {
+ val: '=',
+ //edit: '=',
+ },
+ link: function (scope, element, attrs) {
+ // this is more complicated then it should be
+ // see: https://github.com/angular/angular.js/issues/898
+
+ //var childScope = scope.$new();
+
+
+ var buildDom = function (object) {
+ var html = '';
+ if (object == undefined) {
+ html += 'null';
+ } else if (object instanceof Array) {
+ var i;
+ html += '
['
+ for (i = 0; i < object.length; i++) {
+ html += buildDom(object[i]) + ', ';
+ }
+ html += ']
'
+ } else if (object instanceof Object) {
+ for (prop in object) {
+ if (object.hasOwnProperty(prop)) {
+ html += '' + prop + ': ' + buildDom(object[prop]) + '
';
+ }
+ }
+ } else {
+ html += '' + object.toString() + '';
+ }
+ return html;
+ };
+
+ scope.$watch('val', function (newVal, oldVal) {
+ // TODO: clean up scopes
+ element.html(buildDom(newVal));
+ //$compile(element.contents())(scope);
+ });
+ }
+ };
+});
diff --git a/js/directives/modelTree.js b/js/directives/modelTree.js
index 2d79728..41a3f7e 100644
--- a/js/directives/modelTree.js
+++ b/js/directives/modelTree.js
@@ -14,18 +14,19 @@ panelApp.directive('batModelTree', function($compile) {
element.append(
'' +
'
Scope ({{val.id}}) | ' +
- '
toggle' +
- '
' +
- '
' +
+ '
scopes | ' +
+ '
models' +
+
+ '
' +
+ '' +
+ '
' +
+
+ '
' +
+
'
');
$compile(element.contents())(scope.$new());
diff --git a/js/services/appContext.js b/js/services/appContext.js
index fed55a7..dd149fa 100644
--- a/js/services/appContext.js
+++ b/js/services/appContext.js
@@ -95,18 +95,15 @@ panelApp.factory('appContext', function(chromeExtension) {
// copy scope's locals
node.locals = {};
- for (var i in scope) {
- if (i[0] !== '$' && scope.hasOwnProperty(i) && i !== 'this') {
- if (typeof scope[i] === 'number' || typeof scope[i] === 'boolean') {
- node.locals[i] = scope[i];
- } else if (typeof scope[i] === 'string') {
- node.locals[i] = '"' + scope[i] + '"';
- } else {
- node.locals[i] = JSON.stringify(decycle(scope[i]));
- }
+ var scopeLocals = {};
+ for (prop in scope) {
+ if (scope.hasOwnProperty(prop) && prop !== 'this' && prop[0] !== '$') {
+ scopeLocals[prop] = scope[prop];
}
}
+ node.locals = decycle(scopeLocals);
+
node.id = scope.$id;
if (window.__ngDebug) {
diff --git a/panel.html b/panel.html
index 178e9e5..b8157d8 100644
--- a/panel.html
+++ b/panel.html
@@ -16,6 +16,7 @@
+