I have places in my code where I have this:
I would like to be able to use it like
You can do this with the built-in ngAttr attribute bindings.
The autofocus attribute will be added if SOME_SCOPE_VARIABLE is defined (even if it's false), and will be removed if it's undefined. So I force falsy values to be undefined.
SOME_SCOPE_VARIABLE
false
undefined
$scope.SOME_SCOPE_VARIABLE = someVar || undefined;