search

Home  >  Q&A  >  body text

angular.js - angular two-way binding problem

As shown in the picture, my list and modification are bound to vm.itemObj. If I process it when the pop-up window comes out, it will not be submitted to the backend, because Two-way binding will also change the list. How to solve this

为情所困为情所困2841 days ago603

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-05-15 17:10:13

    Use obj=angular.copy(vm.itemObj) to process the modification in the pop-up window controller. When returning the page controller, re-assign obj to the page controller

    reply
    0
  • 高洛峰

    高洛峰2017-05-15 17:10:13

    One binds vm.itemObj and one binds vm.itemObjCache.

    When the modification is confirmed, the value of vm.itemObjCache['xxx'] is overwritten to vm.itemObj['xxx']

    reply
    0
  • 迷茫

    迷茫2017-05-15 17:10:13

    Using different controllers for pop-ups and lists will avoid this situation.

    reply
    0
  • Cancelreply