Stanislav Korjus Stanislav Korjus - 11 months ago 62
CSS Question

How to using ng-repeat select all element, but without some class

How can I use ng-repeat to select all elements but exclude all of them which have a class


Screen shot

I am using:
element.all(by.repeater('bookmaker in vm.bookmakers'))

What needs to be added here to get a result without elements with class


From looking at your screenshot, you add class 'bookmaker-disabled' when bookmaker.disabled is true. Well as per your code, you could add an ng-if="!bookmaker.disabled" to show only when not disabled, and remove elements which has disabled. In which case you needn't add the class.

Alternatively you could filter out those results which has bookmaker disabled, eg: <div ng-repeat='bookmaker in vm.bookmakers | filter: {disabled: false}'>

Or you could use map reduce inside your controller if that was what you were looking for.

If you are using protractor, This might work:

element.all(by.repeater('bookmaker in vm.bookmakers')).filter(function(elem, index) {
  return elem.getAttribute('class').then(function(classes) {
    return classes.indexOf('bookmaker-disabled') === -1;