I have ng-repeat on a div that contains a button. Say the div repeats 5 times with 5 buttons. I want to disable the 2nd button when it is clicked. How can I disable the button at that index?
<div ng-repeat='thing in things'>
<button ng-click='clickToDisable($index)'>button</button>
</div>
Something like this. I tried ng-disabled= 'disableButton == $index but that just disables all of the buttons.
You can pass in the
$eventinto the click function and set the disabled attribute to true, like this:And in the controller:
Here is a fiddle of it working.