-2
(( (table1.field1 like 'HR%') OR (table1.field1 like 'ABC%' OR table1.field1 like 'XYZ%') )) 
Ruli
  • 2,592
  • 12
  • 30
  • 40

1 Answers1

0

table1.field1 like 'HR%' OR table1.field1 like 'ABC%' OR table1.field1 like 'XYZ%'

Instead of having all that logic in the html if the table1.field1 isnt going to change all that often then its best to set the boolean value once in a method and then ng-if that boolean value. This way your html does not have to do all that work on every digest cycle. Secondly, you can step through your code a lot easier in the controller rather than the HTML. Also makes the HTML cleaner.

// in controller
function ControllerFn($scope) {

    $scope.vm = {
        show: false;
    }


    function toShow(field) {
        if (!field)
            return false;
            
        return field.indexOf('HR') > -1 || field.indexOf('ABC') > -1 || field.indexOf('XYZ') > -1;
    }
    
    if (table1) {
        $scope.vm.show = toShow(table1.field1);
    }
}


// html
<div ng-if='vm.show'></div>
Esaith
  • 706
  • 9
  • 12