Max Koretskyi
Max Koretskyi

Reputation: 105439

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?

Upvotes: 2

Views: 44

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657008

<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.

Upvotes: 2

Related Questions