Reputation: 107
I have some Angular2 code:
<img [src]="value">
and
<img src="{{value}}">
Note: value is a property component
I tested myself and the result is the same, so what is the difference between them ?
Upvotes: 1
Views: 109
Reputation: 214175
They are both properties bindings
Interpolation
<img src="{{value}}">
is just sugar for
<img [src]="interpolate(value)">
So the difference between those expressions is that the value in the interpolation src="{{value}}"
is always stringified while the value of basic property binding [src]="value"
is passed as is.
See also
Upvotes: 2
Reputation: 55443
1) NOTE : don't use ""
& {{}}
together else value will be stringified.
src="{{value}}"
value
will always be stringified.
Here, value
is an expression
which will be evaluated for the property binding
.
[src]
to be precise, this is an angular2 way property binding
syntax.
<img [src]="value">
So, it will bind value's
evaluated value to src property
.
Upvotes: 0