-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng-json-editor.js
34 lines (23 loc) · 884 Bytes
/
ng-json-editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
angular.module( 'JSONEditor', [] )
.directive( 'jsoneditor', function() {
return {
restrict: 'A',
link: function( scope, element, attrs ) {
if( !scope.hasOwnProperty('jsoneditor') ) scope['jsoneditor'] = {
_: {
init: function( element_id, editor_id ) {
var editor = new JSONEditor(document.getElementById(element_id));
scope.jsoneditor.editors[editor_id] = editor;
return true;
}
},
editors: {}
};
var editor_id = attrs.jsoneditor;
var element_id = 'jsoneditor_' + editor_id;
element.html( '<div id="' + element_id + '" class="jsoneditor"></div>' );
scope.jsoneditor._.init(element_id, editor_id);
}
};
} )
;