javascript - Add to array in JSON representing keyed server data in AngularJS? -


I have an application where we have a survey in which we want to add the terms and conditions. As a result, I am trying to add value to the JSON object which returns the client to load. I am using NG-Repetition through an array representing "rule" through an array, in which there are array representing "situations" which will be displayed as elements of the first array . I am trying to explain how to represent the new elements which will not be created until the ID, unless it is submitted to the server and added to the database and still represented by the forms generated in angular : ("Rule": 1235, "question etc.": 5, "effect": "show", "conditions": [{"conditionId": 1, "question id "," Operator ":"} "," value ": 2}, {" conditionId ": 2," question id ": 2," operator ":" ~ = "," va Lue ":" hide me "}}}, {}]}

The following data is presented in HTML as follows:

   Div ng-repeat = "rule in rule.rules" class = "" & gt; & Lt ;! - Display the form to modify the rule's data - & gt; & Lt; Div ng-repeat = "rule.condition condition" & gt; & Lt ;! - Status Details - & gt; & Lt; / Div & gt; & Lt; A ng-click = "survey.add condition (rule) & gt; (+) add condition & lt; / a & gt; & lt; / div & gt; & lt; a ng-click =" survey.ADUUl ) & Gt; Add (+) Rule & lt; / A & gt;  

I have created a way to add to the array of rules and their situations, but when I try to add more than one I get the ID conflict because app ruleId and conditionId Using Indexing I do not want to specify the random ID in the application's data without the actual ID, but there is a better method I can do so that I can send them to the server and save them in the database.


Comments