Angular.js How to update the scope from a directive?

前端 未结 1 1127
花落未央
花落未央 2020-12-31 04:20

How can I update scope in directive?

My directive:



        
相关标签:
1条回答
  • 2020-12-31 05:05

    Use $apply method:

      element.click(function() {
          scope.$apply(function(){
               scope.text = '2';
          });
      });
    

    Explanation: How does data binding work in AngularJS?

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