search

Home  >  Q&A  >  body text

angular.js - Let’s talk about two-way data binding in web development

What are the advantages and disadvantages of two-way data binding?

習慣沉默習慣沉默2776 days ago660

reply all(3)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:52:37

    One-way data binding: It means that we write the template first, then integrate the template and data (the data may come from the background) to form HTML code, and then insert this HTML code into the document flow.

    Disadvantages of one-way data binding: Once the HTML code is generated, there is no way to change it. If new data comes, the previous HTML code must be removed, and then the new data and template must be integrated again. Inserted into the document flow.

    Two-way data binding: Two-way binding between data model (Module) and view (View).

    The user's modifications to the view will be automatically synchronized to the data model. Similarly, if the values ​​in the data model change, they will be synchronized to the view immediately.

    The advantage of two-way data binding is that there is no need to perform CRUD (Create, Retrieve, Update, Delete) operations that are required for one-way data binding

    The most common application scenario for two-way data binding is forms. In this way, after the user completes input on the front-end page, we have already obtained the user's data and stored it in the data model without any operation.

    Currently. Front-end frameworks that implement two-way data binding mainly include AngularJS, VueJS, etc.

    However, I always feel that the application scenarios of two-way data binding are very limited.
    The explanation for why backbonejs does not implement two-way data binding: The general meaning is that two-way data binding is rarely used in actual applications and is not necessary

    "Two way data-binding" is avoided. While it certainly makes for a nifty demo, and works for the most basic CRUD, it doesn't tend to be terribly useful in your real-world app. Sometimes you want to update on every keypress, sometimes on blur, sometimes when the panel is closed, and sometimes when the "save" button is clicked. In almost all cases, simply serializing the form to JSON is faster and easier. All that aside, if your heart is set , go for it.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 16:52:37

    Some people think that two-way binding is too violent, but Angular seems to be able to set whether it is two-way or one-way
    In addition, data binding requires a certain amount of overhead, but testing shows that there seems to be no problem monitoring thousands of variables
    Then the only problem is that angular-js is more than 170 kb compressed. . And angular-js will give up support for ie8

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-15 16:52:37

    What does two-way data binding mean? Can you please tell me

    reply
    0
  • Cancelreply