angular/angular.js — pull request #4269 by caitp (2013-10-03 22:20:04+00:00)
Title: feat(ngAttr): Conditional attribute directive.

Based on ngClass, this directive allows for attributes to be conditionally
applied to an element. It also supports attributes with interpolated values.

1) Simple case: `ng-attr="{checked: isChecked}"`
- The `checked` attribute is added (with no value) when isChecked is
truthy,
and removed when isChecked is falsy. 2) With values:
`ng-attr="'data-whatever={{value}}'"`
- data-whatever has the value of `value` from scope 3) Set of attributes
with interpolated values: `ng-attr="['attr1={{a}}', 'attr2={{b()}}']"`
- Space separation isn't quite enough, but this still allows for some
interesting stuff.

---

Someone asked about a way to do this the other night in #angularjs, so I wrote
this directive just for fun. I thought I'd submit it just in case anyone felt
it would be useful in any way.

If it feels useful, I'm happy to write up some good documentation for it --
However, I'm not totally sure what the real use cases for this are.