ng-bind-templateChỉ thị AngularJS


Thí dụ

Liên kết hai biểu thức với phần tử <p>:

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

Định nghĩa và Cách sử dụng

Lệnh ng-bind-templateyêu cầu AngularJS thay thế nội dung của một phần tử HTML bằng giá trị của các biểu thức đã cho.

Sử dụng ng-bind-templatechỉ thị khi bạn muốn liên kết nhiều hơn một biểu thức với phần tử HTML của mình.


Cú pháp

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

Được hỗ trợ bởi tất cả các phần tử HTML.


Giá trị tham số

Value Description
expression One or more expressions to evaluate, each surrounded by {{  }}.