Angularjs 1.5 component modal with callback function that is called multiple times by embedded Object in IE11 not updating Angular binding

前端 未结 1 1333
面向向阳花
面向向阳花 2021-01-25 12:56

In IE 11, I have an Angularjs 1.5 modal component as below. The modal opens and on render event it calls a function outside of the angular app with a callback function contained

1条回答
  •  抹茶落季
    2021-01-25 13:29

    Use the $timeout service to force a browser tick:

      function callback(message){
        $timeout(function() {
           ctrl.messages.push(message);
           console.log(ctrl.messages[ctrl.messages.length - 1]);
        });
        ̶C̶h̶e̶c̶k̶S̶c̶o̶p̶e̶B̶e̶f̶o̶r̶e̶A̶p̶p̶l̶y̶(̶)̶;̶
      }
    

    If the updates to the message occur all in the same browser tick, only the last update will be rendered. The $timeout service does both a framework digest cycle and a browser rendering cycle.

    For more information, see AngularJS $timeout Service API Reference

    0 讨论(0)
提交回复
热议问题