Created
January 9, 2015 04:27
-
-
Save shaunxu/a8508bfd12a6826a820d to your computer and use it in GitHub Desktop.
Demo on how to use ui-json-editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="MyApp"> | |
<head> | |
<link rel="stylesheet" href="jsoneditor.css" /> | |
</head> | |
<body> | |
<h1>Hello AngularJS-JSONEditor</h1> | |
<div ng-controller="MyCtrl"> | |
<div data-ui-json-editor data-ng-model="json"></div> | |
<pre>{{json | json}}</pre> | |
</div> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script> | |
<script src="jsoneditor.js"></script> | |
<script src="ui.jsoneditor.js"></script> | |
<script> | |
var app = angular.module('MyApp', ['ui.jsoneditor']); | |
app.config(['jsoneditorOptionsProvider', | |
function(jsoneditorOptionsProvider) { | |
jsoneditorOptionsProvider.setOptions({ | |
name: 'root', | |
modes: ['text', 'tree'] | |
}); | |
} | |
]); | |
app.controller('MyCtrl', function($scope) { | |
$scope.editor = {}; | |
$scope.json = { | |
firstName: 'Shaun', | |
lastName: 'Xu', | |
skills: [ | |
'C#', | |
'JavaScript' | |
], | |
roles: [ | |
'dev', | |
'speaker' | |
] | |
}; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment