and Note. Val...">

Difference between two types of data display in Angular 2

I have Angular2 code:

<img [src]="value"> 

and

 <img src="{{value}}"> 

Note. Value is a component of a property

I tested myself and the result is the same, so what is the difference between the two?

+1
angular
Oct 23 '16 at 7:58
source share
2 answers

1) NOTE : do not use "" and {{}} together else the value will be compressed.

 src="{{value}}" 

value will always be gated .




2)

Here value is the expression that will be evaluated for property binding .

[src] , this is the syntax of property binding angular2.

  <img [src]="value"> 

Thus, it will bind the value's to the src property .

0
Oct 23 '16 at 8:09
source share

They are both property bindings.

Interpolation

 <img src="{{value}}"> 

- it's just sugar for

 <img [src]="interpolate(value)"> 

Thus, the difference between these expressions is that the value in the interpolation src="{{value}}" always gated , while the binding value of the base property [src]="value" is passed as.

see also

+1
Oct 23 '16 at 8:02
source share



All Articles