search

Home  >  Q&A  >  body text

javascript - angularJS triggers click event and reports $rootScope:inprog error

I wrote a table in angularJS, and then found a piece of code on the Internet to export the data to excel. JavaScript is OK, but when I put the code into angular,

this error will be reported when the click event is triggered

, I checked online and found that the error was reported because there were multiple $ executions. Others were caused by $apply in angular, but how could the JavaScript click event cause such an error? I'm really confused, please give me some advice...

巴扎黑巴扎黑2704 days ago836

reply all(2)I'll reply

  • 迷茫

    迷茫2017-07-05 10:37:55

    Wrap the code that calls the click event with setTimeout() and try it

    reply
    0
  • PHP中文网

    PHP中文网2017-07-05 10:37:55

    There is $timeout inside angularjs
    First inject $timeout into your controller
    $timeout(function() {

      ...    // 执行你的click代码

    });

    reply
    0
  • Cancelreply