在html的界面中 {{a}}為什么輸出的是
html
<span class="ng-binding ng-scope"> 4 </span>
而我期望的是
html
4
是否有遇到過的大神幫忙解惑~
學習是最好的投資!
引自官網(wǎng):
The
ngBind
attribute tells Angular to replace the text content of thespecified HTML element
with the value of a given expression, and to
update the text content when the value of that expression changes.
意思就是ngBind
會告訴angular去將你寫的表達式替換成一個特殊的html元素
。
而這個特殊的html元素
就是那個帶class的span了,
雙花括號{{}}
和ngBind
是一樣的,實際上是一個directive
,只在適用范圍有稍許區(qū)別
官方文檔ngBind
謝邀。在angular的源碼中可以看到 https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1...
其實就是為了給這個"頂級文本節(jié)點"綁定數(shù)據(jù)用的