summerstyle / jsonTreeViewer

json formatter/viewer/pretty-printer (with jsonTree javascript-library)

Home Page:http://summerstyle.github.io/jsonTreeViewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AngularJS Directive

San-Jeevan opened this issue · comments

this is not a bug, but a contribution.
I made an angularjs directive for this.

.directive('jsonTree', function () {
     return {
         restrict: 'EA',
         scope: {
             data: '=',
             expandall: '&',
             collapseall: '&'
         },
         template: '<div></div>',
         link: function ($scope, element, attrs) {
             var tree;
            tree = jsonTree.create($scope.data, element[0]);
         } 
     }
 });

html syntax:
<div json-tree data="inspector.reqbody">Invalid json-data, check RAW format</div>

data is the json object.

obviously collapseall and expandall functionality is not there yet, but this is a good starting point

hi,

sorry, but I don't know angular.js good enough and I can't create solution for this problem.