在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:krispo/json-tree开源软件地址:https://github.com/krispo/json-tree开源编程语言:JavaScript 78.7%开源软件介绍:Editable JSON treeAn AngularJS directive used for displaying and editing JSON data in a tree view. It works independently of jQuery (only internal angular's jqLite). Available operations with nodes:
How to useInstallbower
An AngularJS would be installed as a dependency automatically. If it won't, install it manually:
Add dependencies to the <script src="bower_components/angular/angular.js"></script>
<script src="bower_components/json-tree/json-tree.js"></script>
<link rel="stylesheet" href="bower_components/json-tree/json-tree.css"> If you don't use bower, you can manually download and unpack json-tree (zip, tar.gz). npm
Basic usageInject angular.module('myApp', ['json-tree'])
.controller('myCtrl', function('$scope'){
$scope.jsonData = { /* JSON data */ };
}) and in html again you can use it like: <div ng-app='myApp'>
<div ng-controller='myCtrl'>
<json-tree json='jsonData'></json-tree>
</div>
</div> By default, it is used a high edit level that allows you to add new nodes, reset node values to null, completely remove node, change value and type of the node (to object, array, string, number, boolean, function, null), drag and sort tree nodes. If you want to operate only with key-values of the nodes and to avoid transformation of json tree, you can add low <json-tree json='jsonData' edit-level='low'></json-tree> You can also customize initial depth of tree view by adding <json-tree json='jsonData' collapsed-level='2'></json-tree> If You can completely refresh directive by using directive internal refresh function. To access this function just add <json-tree json='jsonData' node='nodeOptions'></json-tree> and then use it in controller as: $scope.nodeOptions.refresh(); Drag and sort your tree nodes via pressed Add more style to prettify the view. See complete example in Custom templateThe default template can be overridden by new custom template as follows: angular.module('myApp', ['json-tree'])
.controller('myCtrl', ['$scope', 'jsonTreeConfig', function($scope, jsonTreeConfig){
jsonTreeConfig.templateUrl = 'custom-template.html';
}]); For more details of technically usage, please, watch example online and test it. There is given a short instruction. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论