1

I want to start with a base JSON, ie [], and provide a tree like structure with options to edit node (change or extend existing keys/values), add sibling (create new entry), and add child (extend the json to become a map, ie add { "field1" : "value1", "field2" : "value2"} to "data".

Seems like the best way to do this is to bind a json scope value to a tree structure. I am about to build one myself, but thought I would check to see if it's been done already....

This sort of feature would allow someone closer to the business to define and refine the data model, as well as make simple edits. Think the php myadmin interface, or the django admin page.

3 Answers 3

1

This fiddle will give you a headstart. It was actually referenced from this question. It does not deal with object parameters, just nodes in the tree, but adding these should be pretty straightforward from a controller standpoint. The real challenge is in developing a good-looking view. Here is the controller part (just to make SO happy):

angular.module("myApp", []).controller("TreeController", ['$scope', function($scope) {
  $scope.delete = function(data) {
    data.nodes = [];
  };
  $scope.add = function(data) {
    var post = data.nodes.length + 1;
    var newName = data.name + '-' + post;
    data.nodes.push({name: newName,nodes: []});
  };
  $scope.tree = [{name: "Node", nodes: []}];
}]);
Sign up to request clarification or add additional context in comments.

1 Comment

"Just editing of the tree itself." - That's the part that takes time. Asking if it's been done already. :)
0

Check it out json-tree angularjs directive.

Comments

0

This looks like a good implementation of what you're looking for.

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.