I can't get the &
operator to work in an Angular ng-if
expression (to use with some bit flags). Suppose we have some HTML like this:
<div ng-if=value & 2> </div>
If value
equals 3, then the bitwise operation should return 2 and thus a true value.
However, Angular throws a Syntax Error
exception every time. Is the operation not allowed? Or am I doing something wrong?
Link to the plunker.
Edit: I already resolved my issue by using a simple function that does the job:
$scope.checkFlag = function(value, flag){
return value & flag;
}
But I really don't like this solution. Is there a way to use it in an ng-if
(without using the function, obviously)?