J
J
jershell2014-11-01 09:27:53
JavaScript
jershell, 2014-11-01 09:27:53

What is the best way to update data in html widgets?

There are two html tables written in angular, one is the parent of the other. When you select an item in the parent table, a child table appears. The parent table has a total amount field. And in the child there are goods. When adding a new product, a request is made to the /create server, which, if successful, returns the same product, but with an id and other fields.

How better (even would say more correctly) to organize data update (total amount of goods) in the parent table?

  • Option A The server sends not only the saved product, but also the total amount to update this value in the parent.
  • Option B The server sends the saved product, after which we ourselves (by manual condition) re-read the element in the parent table?
  • Option B We store elements of child tables in elements of parent tables.
    parentItem:{
    childItems:[
        {id:0, titile:"title 1"},
        {id:1, titile:"title 2"},
    ]
    }

    And in case of adding a new product, a helmet instead of /create, /update of the parent element

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2014-11-01
@AMar4enko

I would do option B.
The disadvantage of option A is that it does not agree well with REST and you need to finish the server.
The disadvantage of option B is that it is suitable only if there are few child elements, and the server needs to be finished.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question