Angular 2中2种类型的显示数据之间的区别 [英] Difference between 2 type of displaying data in Angular 2
本文介绍了Angular 2中2种类型的显示数据之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些Angular2代码:
I have some Angular2 code:
<img [src]="value">
和
<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 ?
推荐答案
1) 注意:请勿使用""
& {{}}
一起,否则值将被字符串化.
1) NOTE : don't use ""
& {{}}
together else value will be stringified.
src="{{value}}"
value
将始终被字符串化.
2)
在这里, value
是 expression
,将对 property binding
进行评估.
Here, value
is an expression
which will be evaluated for the property binding
.
[src]
,这是angular2方式的 property binding
语法.
[src]
to be precise, this is an angular2 way property binding
syntax.
<img [src]="value">
因此,它将 value's
评估值绑定到 src property
.
So, it will bind value's
evaluated value to src property
.
这篇关于Angular 2中2种类型的显示数据之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文