Attribute Binding

You must use attribute binding when there is no element property to bind.

e.g. ARIA, SVG, and table span attributes are pure attributes.

When you write something like this

<tr><td colspan="{{1 + 1}}">Three-Four</td></tr>

you get this error

Template parse errors:
Can't bind to 'colspan' since it isn't a known native property

the <td> element does not have a colspan property. It has the "colspan" attribute, but interpolation and property binding can set only properties, not attributes.

Instead, you have to write like this

<tr><td [attr.colspan]="1 + 1">One-Two</td></tr>

Last updated

Was this helpful?