AngularJS ng-click fires twice

后端 未结 18 1807
死守一世寂寞
死守一世寂寞 2020-12-03 07:10

I am using ng-click and it fires twice when I apply it to SPAN tag.

HTML

18条回答
  •  盖世英雄少女心
    2020-12-03 07:36

    I have handled it by following code

    HTML :

  • Angular 1.0 Controller :

    _self.SubmitClick = function(event){   
         _self.desableSubmitButton = true; //disable submit button
         event.preventDefault();
         event.stopPropagation();
    
         setTimeout(funtion() {
           _self.desableSubmitButton = false; //enable submit button after timeout
               if(_self.$scope.$$phase != '$apply' || _self.$scope.$$phase != '$digest'){
                 _self.$scope.$digest();
                 }
          }, 1000);//other Code logic
    }
    

提交回复
热议问题