0

I'm trying to make a general purpose JSON pretty-print using AngularJs.

For an idea what a prettyprinter is: https://github.com/padolsey/prettyPrint.js

I'm not sure how to do this with angular, I am guessing nested transcluded directives, but I am having problems getting nested transcludes to behave properly. (For example: http://plnkr.co/edit/CHsGHCt3SU3N5MCJxwTV?p=preview )

If you could set me down a better path for dynamically generating html based on JSON (using Angular), I'd appreciate it!

1 Answer 1

1

You can modify the angularTreeview source to output the html you want

if( attrs.angularTreeview ) {

    //create tree object if not exists
    scope[treeId] = scope[treeId] || {};

    //if node head clicks,
    scope[treeId].selectNodeHead = scope[treeId].selectNodeHead || function( selectedNode ){

        //Collapse or Expand
        selectedNode.collapsed = !selectedNode.collapsed;
    };

    //if node label clicks,
    scope[treeId].selectNodeLabel = scope[treeId].selectNodeLabel || function( selectedNode ){

        //remove highlight from previous node
        if( scope[treeId].currentNode && scope[treeId].currentNode.selected ) {
            scope[treeId].currentNode.selected = undefined;
        }

        //set highlight to selected node
        selectedNode.selected = 'selected';

        //set currentNode
        scope[treeId].currentNode = selectedNode;
    };
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.