Answer the question
In order to leave comments, you need to log in
What is the difference between One-Way Binding and Two-Way Binding?
Friends,
I'll ask a little strange question.
There is a one-way binding, when the interface displays data from the model, and the data in the model changes only from above, i.e. as a result of processing the event, the model changes, and as a result, an interface is drawn with new data.
There is a two-way one, when the interface can change the model, and the interface will display new data from the model.
It is believed that the difference in the direction of data change, i.e. in a one-way interface, it cannot change the model, but in a two-way one, it can.
Now the million dollar question. In any case, two-way binding under the hood is bound to events (otherwise how to change the model), i.e. according to its logic, this is the same, i.e. there is a model, then we bind to the event, as a result of event processing, the model changes, and then we draw an interface with new data. The same as one-way binding, only it's usually done under the hood (like Angular) and is seen as "two-way" binding by developers.
So what's the difference between them?
Answer the question
In order to leave comments, you need to log in
There is a one-sided ... i.e. as a result of event processing, the model changes
It is necessary to understand literally, and there is no need to invent and fantasize anything, you need to fantasize about something else. With one-way communication, one side responds to changes, the other does not. When bilateral, they both respond to each other's changes.
An example with forms. Here is the data that is displayed in the input field. When you change the data somewhere in the code, the changes are displayed in the input field. But when anyone changes the input field, the data in the code does not change. This is a one-way connection. With double-sided data will change when you enter in the input field.
Single Source of Truth. One-Way Binding allows more trust in the model. This abstraction layer is above the event-loop, there is simply no need to look under the hood.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question