Reputation: 185
Why do some attributes require the "attr." prefix and some don't?
Upvotes: 0
Views: 541
Reputation: 992
Short answer: [title]="myVar"
is property binding whereas [attr.title]="myVar"
is attribute binding.
Attribute binding must be used, when DOM property doesn't exist.
For example, colspan
does not exist DOM property and you must use attr.colspan="..."
. When you try use colspan="..."
you get an error in console.
Read up on attribute binding here.
Upvotes: 1