AngularJS ng-bind-templateDirective

AngularJS 参考手册AngularJS Reference Manual


AngularJS Example

Bind two expressions on the <p> element:

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

Try it Yourself »

Definition and Usage

ng-bind-templateThe directive is used to tell AngularJS to replace the content of an HTML element with the value of a given expression.

You can use theng-bind-templatedirective when you want to bind multiple expressions on an HTML element.


Syntax

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

All HTML elements support this directive.


Parameter Values

Value Description
expression One or more expressions to be executed, each enclosed in {{ }}.

AngularJS 参考手册AngularJS Reference Manual

Other Extensions