AngularJS ng-bind-template 指令详解
- 作者: x孔小强x
- 来源: 51数据库
- 2021-08-23
angularjs ng-bind-template 指令
angularjs 实例
<p> 元素上绑定两个表达式:
<!doctype html> <html> <head> <meta charset="utf-8"> <script src="http://www.51sjk.com/Upload/Articles/1/0/268/268332_20210708023630828.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>
运行结果:
john doe
定义和用法
ng-bind-template 指令用于告诉 angularjs 将给定表达式的值替换 html 元素的内容。
当你想在 html 元素上绑定多个表达式时可以使用 ng-bind-template 指令。
语法
<element ng-bind-template="expression"></element>
所有的 html 元素都支持该指令。
参数值
值 | 描述 |
---|---|
expression | 一个或多个要执行的表达式,每个使用 {{ }} 包含。 |
以上就是对 angularjs ng-bind-template 指令知识介绍,有需要的朋友看下。
推荐阅读
热点文章
Angular中响应式表单的三种更新值方法详析
7
Angularjs实现下拉框联动的示例代码
7
详解AngularJS跨页面传值(ui-router)
2
详解AngularJS1.x学习directive 中‘& ’‘=’ ‘@’符号的区别使用
3
angular2路由切换改变页面title的示例代码
4
Angular2 组件间通过@Input @Output通讯示例
5
Angularjs中ng-repeat的简单实例
3
AngularJS 中ui-view传参的实例详解
4
浅谈Angular路由守卫
4
详解基于Angular4+ server render(服务端渲染)开发教程
4