简体   繁体   中英

Disable button if the selected row contains a specific value ng-grid

I'm trying to disable a remove button for my grid if the row contains a specific value.

I've already have a condition in my ng-disable for the button (and want to keep that), but I want to add a second one, ex:

mySelection.title == 'important'

How till this behave if I select two rows? It won't iterate through the selected rows and check if the rows contains a title with important, so how can I solve this?

use a function() in ng-disabled

for EX:

<button ng-disabled="isDisabled(mySelection.title, parameter2)"> Remove </button>

in controller,

 $scope.isDisabled = function(parameter1, parameter2) {
     // do your comparisons and return true or false 

     // for ex:

     // if(parameter1 == 'important' && parameter2 == 'spmeOtherValue') {
     //     return true;
     // } else {
     //     return false;
     // }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM