angularjs ng-bind-template 指令
angularjs 实例
<p> 元素上绑定两个表达式:
<!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>
运行结果:
john doe
定义和用法
ng-bind-template 指令用于告诉 angularjs 将给定表达式的值替换 html 元素的内容。
当你想在 html 元素上绑定多个表达式时可以使用 ng-bind-template 指令。
语法
<element ng-bind-template="expression"></element>
所有的 html 元素都支持该指令。
参数值
值 | 描述 |
---|---|
expression | 一个或多个要执行的表达式,每个使用 {{ }} 包含。 |
以上就是对 angularjs ng-bind-template 指令知识介绍,有需要的朋友看下。
如对本文有疑问, 点击进行留言回复!!
基于Angular 8和Bootstrap 4实现动态主题切换的示例代码
解决三元运算符 报错“SyntaxError: can''t assign to conditional expression”
解决angular 使用原生拖拽页面卡顿及表单控件输入延迟问题
使用 Angular RouteReuseStrategy 缓存(路由)组件的实例代码
分享Angular http interceptors 拦截器使用(推荐)
网友评论