Chỉ thị ng-bind-template
của AngularJS
Ví 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>
Hãy tự mình thử »Định nghĩa và cách sử dụng
Lệnh ng-bind-template
yê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 lệnh ng-bind-template
khi bạn muốn liên kết nhiều biểu thức với thành phần 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 {{ }}. |