A single bang (!
) is used to negate a boolean.
Double bang (!!
) is used to coerce a truthy/falsey value to a boolean true or false.
for example
var x = 0; // a falsey value
console.log(x); // logs 0
console.log(!x)// logs true
console.log(!!x)// logs false
var y = "Hello world"; // a truthy value
console.log(y); // logs "Hello world"
console.log(!y)// logs false
console.log(!!y)// logs true
Applied to your specific case
ng-show="!!user.rank"
ng-show
is no doubt expecting an actual boolean, and user.rank
is obviously either truthy or falsey - coercing it to a boolean satisfies your angular directive appropriately.