@@ -5,52 +5,52 @@ angular.module('angular-json-editor', [])
5
5
return {
6
6
restrict : 'A' ,
7
7
scope : {
8
- startval : '=' ,
9
- jsonEditor : '=' ,
10
- schemaUrl : '@' ,
11
- editor : '=' ,
12
- isValid : '='
13
- } ,
8
+ startval : '=' ,
9
+ jsonEditor : '=' ,
10
+ schemaUrl : '@' ,
11
+ editor : '=' ,
12
+ isValid : '='
13
+ } ,
14
14
link : function ( scope , element , attrs ) {
15
- var config = {
16
- startval : scope . startval ,
17
- iconlib : attrs . iconlib || 'bootstrap3' ,
18
- theme : attrs . theme || 'bootstrap3'
19
- } ;
15
+ var config = {
16
+ startval : scope . startval ,
17
+ iconlib : attrs . iconlib || 'bootstrap3' ,
18
+ theme : attrs . theme || 'bootstrap3'
19
+ } ;
20
20
21
- if ( scope . jsonEditor ) {
22
- config . schema = scope . jsonEditor ;
21
+ if ( scope . jsonEditor ) {
22
+ config . schema = scope . jsonEditor ;
23
23
24
- } else if ( attrs . schemaUrl ) {
25
- config . ajax = true ;
26
- config . schema = {
27
- $ref : scope . schemaUrl
28
- } ;
24
+ } else if ( attrs . schemaUrl ) {
25
+ config . ajax = true ;
26
+ config . schema = {
27
+ $ref : scope . schemaUrl
28
+ } ;
29
29
30
- } else {
31
- console . error ( 'no schema specified.' ) ;
32
- }
30
+ } else {
31
+ console . error ( 'no schema specified.' ) ;
32
+ }
33
33
34
- var editor = new JSONEditor ( element [ 0 ] , config ) ;
34
+ var editor = new JSONEditor ( element [ 0 ] , config ) ;
35
35
36
- // Attach the editor object to the parent scope, for easy access from a controller.
37
- if ( attrs . editor ) {
38
- scope . editor = editor ;
39
- }
36
+ // Attach the editor object to the parent scope, for easy access from a controller.
37
+ if ( attrs . editor ) {
38
+ scope . editor = editor ;
39
+ }
40
40
41
- // scope.isValid holds the validation state of the entire form.
42
- // it is useful for disabling the submit button while the form isn't valid.
43
- if ( attrs . isValid ) {
44
- scope . isValid = false ;
45
- editor . on ( 'ready' , function ( ) {
46
- scope . isValid = ( editor . validate ( ) . length === 0 ) ;
47
- editor . on ( 'change' , function ( ) {
48
- scope . $apply ( function ( ) {
49
- scope . isValid = ( editor . validate ( ) . length === 0 ) ;
50
- } ) ;
51
- } ) ;
52
- } ) ;
53
- }
41
+ // scope.isValid holds the validation state of the entire form.
42
+ // it is useful for disabling the submit button while the form isn't valid.
43
+ if ( attrs . isValid ) {
44
+ scope . isValid = false ;
45
+ editor . on ( 'ready' , function ( ) {
46
+ scope . isValid = ( editor . validate ( ) . length === 0 ) ;
47
+ editor . on ( 'change' , function ( ) {
48
+ scope . $apply ( function ( ) {
49
+ scope . isValid = ( editor . validate ( ) . length === 0 ) ;
50
+ } ) ;
51
+ } ) ;
52
+ } ) ;
53
+ }
54
54
}
55
55
} ;
56
56
} ) ;
0 commit comments