AngularJS and contentEditable two way binding doesn't work as expected

前端 未结 5 1653
广开言路
广开言路 2020-12-07 18:53

Why in the following example the initial rendered value is {{ person.name }} rather than David? How would you fix this?

Live example here

5条回答
  •  难免孤独
    2020-12-07 19:13

    The problem is that you are updating the view value when the interpolation is not finished yet.

    So removing

    // load init value from DOM
    ctrl.$setViewValue(element.html());
    

    or replacing it with

    ctrl.$render();
    

    will resolve the issue.

提交回复
热议问题