Simple Implementation of AngularJS ng bind Instruction

  • 2021-07-06 10:03:09
  • OfStack

AngularJS ng-bind Directive

AngularJS instance

Binding < p > innerHTML in to 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>

Run 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 HTML element specified for replacement is also modified.

Grammar

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

Or as the CSS class:

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

All HTML elements support this instruction.

Parameter value

描述
expression 指定要执行的变量或表达式。

The above is a detailed introduction to AngularJS ng-bind instructions. Friends who need it can refer to it.


Related articles: