Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9165011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:49:00+00:00 2026-06-17T14:49:00+00:00

I like to build a quick tool to define a JSON-schema which looks like

  • 0

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:

  1. First created a “$scope.newProperties” array, which store the properties I like to add to my schema “$scope.schema“
  2. 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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:49:01+00:00Added an answer on June 17, 2026 at 2:49 pm

    Reset the $scope.schema.properties before iterating through the items:

    $scope.$watch(function(){return $scope.newProperties;},function(items,b){
        $scope.newSchema.properties = {};
        angular.forEach(items, function(obj){
            if(angular.isDefined(obj.key)) {
                var key = obj.key, type = obj.type, name = obj.name;
                $scope.newSchema.properties[key] = {
                    "name": name,
                    "type": type
                };
            }
        });
    },true);
    

    It’s the best way to keep the $scope.schema ordered and synced with the $scope.newProperties

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to build a cypher with python which decoding text by repeatedly
I would like to build up a new IDocument object step by step using
I have a dynamic object built inside IronPython and I would like to build
Quick overview: trying to build a gallery with a string from $_GET ('foo'), which
My code looks like this. @Produces(MediaType.TEXT_XML) public Response getEmpDetails() { Map<String, Employee> result =
Im planning to build a Embedded system which is almost like an organizer i.e.
I'd like to build a site which simply displays the top latest (by date,
In a quick-and-dirty Perl script, I have a data structure like this: $tax_revenue{YEAR}{STATE}{GOVLEV}{TAX} =
I'd like to build a real quick and dirty administrative backend for a Ruby
I'm trying to build a quick tool using LogMeIn's Rescue API. Basically what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.