Difference between 2 type of displaying data in Angular 2

前端 未结 2 1638
天命终不由人
天命终不由人 2021-01-25 07:19

I have some Angular2 code:


and


Note:

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 08:11

    They are both properties bindings

    Interpolation

    
    

    is just sugar for

    
    

    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

    • What's the difference between `value="{{todo.title}}"` and `[value]="todo.title"`?
    • Angular 2 Template Syntax

提交回复
热议问题