How to make an ng-click event conditional?

后端 未结 6 466
既然无缘
既然无缘 2020-12-07 15:03

I have this code inside ng-repeat:

Do something

H

6条回答
  •  抹茶落季
    2020-12-07 15:56

    You could try to use ng-class.
    Here is my simple example:
    http://plnkr.co/edit/wS3QkQ5dvHNdc6Lb8ZSF?p=preview

    {{object.value}}

    The status is a custom attribute of object, you could name it whatever you want.
    The disabled in ng-class is a CSS class name, the object.status should be true or false

    You could change every object's status in function disableIt.
    In your Controller, you could do this:

    $scope.disableIt = function(obj) {
      obj.status = !obj.status
    }
    

提交回复
热议问题