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. |