Jonathan Miles Jonathan Miles - 1 year ago 176
AngularJS Question

How to add conditional attribute in Angular 2?

How can I conditionally add an element attribute e.g. the

of a checkbox?

Previous versions of Angular had
and I think
which all seem to provide the functionality that I'm after. However, these attributes do not appear to exist in Angular 2 and I see no other way of providing this functionality.

Answer Source

null removes it:

[attr.checked]="value ? true : null"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download