AngularJS ng-bind
指令
示例
將 <p> 元素的 innerHTML 繫結到變數 myText
<div ng-app="" ng-init="myText='Hello World!'">
<p ng-bind="myText"></p>
</div>
自己動手試一試 »
定義和用法
The ng-bind
directive tells AngularJS to replace the content of an HTML element with the value of a given variable, or expression.
If the value of the given variable, or expression, changes, the content of the specified HTML element will be changed as well.
語法
<element ng-bind="expression"></element>
Or as a CSS class
<element class="ng-bind: expression"></element>
所有 HTML 元素均支援。
引數值
值 | 描述 |
---|---|
expression | Specifies a variable, or an expression to evaluate. |