<p> 元素上綁定兩個表達式:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-bind-template="{{firstName}} {{lastName}}" ng-controller="myCtrl">
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
</body>
</html>測試看看 ?/?ng-bind-template 指令用于告訴 AngularJS 將給定表達式的值替換 HTML 元素的內(nèi)容。
當你想在 HTML 元素上綁定多個表達式時可以使用 ng-bind-template 指令。
<element ng-bind-template="expression"></element>
所有的 HTML 元素都支持該指令。
| 值 | 描述 |
|---|---|
| expression | 一個或多個要執(zhí)行的表達式,每個使用 {{ }} 包含。 |