AngularJS ng-bind 指令

定义和用法

ng-bind Directives tell AngularJS to replace the content of the HTML element with the value of the given variable or expression.

If the value of the given variable or expression changes, the content of the specified HTML element will also change.

If the value of the given variable or expression changes, the content of the specified HTML element will also change.

Example

Bind the innerHTML of the <p> element to the variable myText:

<div ng-app="" ng-init="myText='Hello World!'">
<p ng-bind="myText"></p>
</div>

Try It Yourself

Syntax

<element ng-bind="expression</element>

or as a CSS class:

<element class="ng-bind: expression</element>

All HTML elements are supported.

Parameters

Parameters Description
expression Specify the variable or expression to be calculated.