AngularJS ng-bind-template 指令詳解
AngularJS ng-bind-template 指令
AngularJS 實(shí)例
<p> 元素上綁定兩個(gè)表達(dá)式:
<!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="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>
運(yùn)行結(jié)果:
John Doe
定義和用法
ng-bind-template 指令用于告訴 AngularJS 將給定表達(dá)式的值替換 HTML 元素的內(nèi)容。
當(dāng)你想在 HTML 元素上綁定多個(gè)表達(dá)式時(shí)可以使用 ng-bind-template 指令。
語(yǔ)法
<element ng-bind-template="expression"></element>
所有的 HTML 元素都支持該指令。
參數(shù)值
| 值 | 描述 |
|---|---|
| expression | 一個(gè)或多個(gè)要執(zhí)行的表達(dá)式,每個(gè)使用 {{ }} 包含。 |
以上就是對(duì) AngularJS ng-bind-template 指令知識(shí)介紹,有需要的朋友看下。
- 深入理解AngularJS中的ng-bind-html指令
- 深入理解AngularJS中的ng-bind-html指令和$sce服務(wù)
- AngularJS ng-bind-html 指令詳解及實(shí)例代碼
- AngularJS ng-bind 指令簡(jiǎn)單實(shí)現(xiàn)
- ANGULARJS中用NG-BIND指令實(shí)現(xiàn)單向綁定的例子
- AngularJS基礎(chǔ) ng-model 指令詳解及示例代碼
- Angular.js回顧ng-app和ng-model使用技巧
- angularjs在ng-repeat中使用ng-model遇到的問(wèn)題
- Angular中ng-bind和ng-model的區(qū)別實(shí)例詳解
相關(guān)文章
Angular2.0/4.0 使用Echarts圖表的示例代碼
解決Angular4項(xiàng)目部署到服務(wù)器上刷新404的問(wèn)題
自定義Angular指令與jQuery實(shí)現(xiàn)的Bootstrap風(fēng)格數(shù)據(jù)雙向綁定的單選與多選下拉框
angular inputNumber指令輸入框只能輸入數(shù)字的實(shí)現(xiàn)

