I like to build a quick tool to define a "JSON-schema" which looks like this:
{
"type": "object",
"properties": {
"myFirstProperty": {
"type": "integer"
}
},
"title": "MySchema",
"description": "some description"
}
See the preview here: http://jsfiddle.net/franquis/djRFN/4/embedded/result/
See the code here: http://jsfiddle.net/franquis/djRFN/4/
Using a simple form, I can define the "name", "description" using the "ng-model" attributes, but when it comes to the "properties" definition of my schema, I have some troubles :)
What I did is:
- First created a "$scope.newProperties" array, which store the properties I like to add to my schema "$scope.schema"
- Added a listener on this array in order to add new properties to my "$scope.schema.properties"
My issues:
When I created a new property, while I typing the name of the new key (ie hostname), it creates a lot of new properies... See below:
{
"type": "object",
"properties": {
"h": {},
"ho": {},
"hos": {},
"host": {},
"hostn": {},
"hostna": {},
"hostnam": {},
"hostname": {
"type": "integer"
}
},
"title": "MySchema",
"description": "some description"
}
I know this behavior is caused by the "$watch("myva",function(a,b){},true);" function, but what else can I try to succeed?
Thanks for your help!