Maximus Maximus - 16 days ago 6
Javascript Question

Difference between binding using [] syntax and without

I have a custom

my-table
with the property
row
bound to the host component. I can put html in two ways:

<my-table [rows]="displayEntriesCount"></my-table>


and like this:

<my-table rows="{{displayEntriesCount}}"></my-table>


what's the difference?

Answer
<my-table [rows]="displayEntriesCount"></my-table>

binds the value in displayEntriesCount as is

<my-table rows="{{displayEntriesCount}}"></my-table>

does string interpolation. This means the assigned value is the stringified value of displayEntriesCount. Don't use this if you want to assign object values.

Comments