Angular JS views not updating properly

前端 未结 2 866
-上瘾入骨i
-上瘾入骨i 2021-02-07 07:35

I have the following action

ng-click in my view -> which inturn calls a jQuery ajax function that displays jQuery Qtip

2条回答
  •  被撕碎了的回忆
    2021-02-07 07:50

    As the docs explains:

    $apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular framework we need to perform proper scope life-cycle of exception handling, executing watches.

    So if you have a jQuery code like

    $('#myDiv').on('click', function() {
      // do stuff
      $scope.$apply();
    });
    

提交回复
热议问题