I have a basic ng-show expression as follows:
ng-show="((message.status & messageStatus.Spam) != 0)"
However, this fails with the following msg: "Token '&' is unexpected, expecting [)] at column 18 of the expression".
Does Angular support bitwise operations, or do I need to write a function to evaluate something as simple as that?
The Bitwise Not operation treats the sign bit as it would any other bit. If the input for a pixel location is negative, the output is negative; if the input is positive, the output is positive. If the input is a multiband raster, the output will be a multiband raster.
Bitwise NOT (~)Each bit in the operand is inverted in the result. The 32-bit signed integer operand is inverted according to two's complement. That is, the presence of the most significant bit is used to express negative integers. Bitwise NOTing any number x yields -(x + 1) .
These operators are used to perform bit operations. Decimal values are converted into binary values which are the sequence of bits and bit wise operators work on these bits. Bit wise operators in C language are & (bitwise AND), | (bitwise OR), ~ (bitwise NOT), ^ (XOR), << (left shift) and >> (right shift).
From the angularjs github buglist: https://github.com/angular/angular.js/issues/2838
http://docs.angularjs.org/guide/expression "Angular Expressions vs. JS Expressions It might be tempting to think of Angular view expressions as JavaScript expressions, but that is not entirely correct, since Angular does not use a JavaScript eval() to evaluate expressions."
You can use a filter to achieve the effect as such:
angular.module('project', [])
.filter('bitwiseAnd', function () {
return function (firstNumber, secondNumber) {
return ((parseInt(firstNumber, 10) & parseInt(secondNumber, 10)) === parseInt(secondNumber, 10));
// return firstNumber % secondNumber > 0
};
});
It doesn't support according to the doc.
Thought it mentioned '|'
on the doc but don't get confused, '|'
is not bitwise OR
it is Angularjs's filter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With