AngularJS ng-bind directive
AngularJS instance
Bind innerHTML within <p> to the variable myText:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body><div ng-app="" ng-init="myText='Hello World!'"><p ng-bind="myText"></p></div></body></html>
Running results:
Hello World!
Definition and usage
The ng-bind directive tells AngularJS to replace the contents of an HTML element with the value of a given variable or expression.
If the given variable or expression is modified, the specified replacement HTML element is also modified.
grammar
<element ng-bind="expression"></element>
Or as a CSS class:
<element></element>
All HTML elements support this directive.
Parameter value
| value | describe |
|---|---|
| Expression | Specifies the variable or expression to be executed. |
The above is a detailed introduction to the AngularJS ng-bind directive. Friends who need it can refer to it.