Attribute value binding: square brackets vs curly brackets

前端 未结 2 625
醉梦人生
醉梦人生 2021-01-17 20:18

I\'ve downloaded Angular CLI 6.0.7 for Node and am playing around with it, following tutorials, etc. to learn as much as possible.

One thing I have a question about

2条回答
  •  孤独总比滥情好
    2021-01-17 20:40

    They're both effectively the same. You are binding one-way from component to view. However, there are some cases when you must use one over other.

    For example, if you want to achieve string concatenation you must use interpolation (E.g., {{ }}).

    
    

    you can't achieve above using property binding.

    On the other hand, when you want to bind non-string value to HTML element, you must use property binding (E.g., [])

    
    

提交回复
热议问题