[AngularJS] Taking control of your templates using $templateCache
Using $templateCache for quickly retrieval from the cache after first time used.
$templateCache mainly can use two methods:
- get(id)
- put(id, "your html code here")
angular.module('app', [])
.directive('myButton', function () {
return {
templateUrl: 'timestamp'
}
})
.run(function ($templateCache) {
$templateCache.put('timestamp', '<button>' + Date.now() + '</button>');
});
or you can but your template in the <script> tag, then use templateCache.get() method:
<script type="text/ng-template" id="templateId.html">
<button>Date.now()</button>
</script>
angular.module('app', [])
.directive('myButton', function ($templateCache) {
return {
templateUrl: $templateCache.get('templateId.html')
}
})
[AngularJS] Taking control of your templates using $templateCache的更多相关文章
- AngularJs学习笔记--Understanding Angular Templates
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model angular template是一个声明规范,与mode ...
- [Whole Web] [AngularJS + Grunt] Using ng-html2js to Convert Templates into JavaScript
ng-html2js takes .html templates and converts them into strings stored in AngularJS's template cache ...
- angularJs $templateCache
模板加载后,AngularJS会将它默认缓存到 $templateCache 服务中.在实际生产中,可以提前将模板缓存到一个定义模板的JavaScript文件中,这样就不需要通过XHR来加载模板了 $ ...
- AngularJs学习笔记--Forms
原版地址:http://code.angularjs.org/1.0.2/docs/guide/forms 控件(input.select.textarea)是用户输入数据的一种方式.Form(表单) ...
- AngularJs学习笔记--expression
原版地址:http://code.angularjs.org/1.0.2/docs/guide/expression 表达式(Expressions)是类Javascript的代码片段,通常放置在绑定 ...
- AngularJS config run 及区别和例子
一.config方法 在模块加载阶段,对模块进行自定义配置 config可以注入$stateProvider, $urlRouterProvider, $controllerProvider, $pr ...
- AngularJs学习笔记--Dependency Injection(DI,依赖注入)
原版地址:http://code.angularjs.org/1.0.2/docs/guide/di 一.Dependency Injection(依赖注入) 依赖注入(DI)是一个软件设计模式,处理 ...
- angularJS——自定义指令
主要介绍指令定义的选项配置 //angular指令的定义,myDirective ,使用驼峰命名法 angular.module('myApp', []) .directive('myDirectiv ...
- Angularjs学习---angularjs环境搭建,ubuntu 12.04下安装nodejs、npm和karma
1.下载angularjs 进入其官网下载:https://angularjs.org/,建议下载最新版的:https://ajax.googleapis.com/ajax/libs/angular ...
随机推荐
- 浏览器以外的Javascript
浏览器外要运行javascript的代码,同样需要这个东西. ie老版本的JScript,ie9以后的Chakra,mozilla的SpiderMonkey,chrome的v8,Safari的Nitr ...
- I.MX6 U-boot PWM hacking
/******************************************************************************* * I.MX6 U-boot PWM ...
- DB2创建序列
一.创建序列 序列是按照一定的规则生产的数值,序列的作用非常的大,比如银行交易中的流水号,就是记录每笔交易的关键字段. 通过create sequence语句创建序列,具体语法如下: >> ...
- (转)MySQL数据库引擎ISAM MyISAM HEAP InnoDB的区别
转自:http://blog.csdn.net/nightelve/article/details/16895917 MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎 ...
- SharePoint 2010 自定义 字段 类型--------省市区联动
转:http://www.cnblogs.com/sp007/p/3384310.html 最近有几个朋友问到了有关自定义字段类型的问题,为了让更多的人了解自定义字段类型的方法,特写一篇博客与大家分享 ...
- Button 自定义(一)-shape
需求:自定义Button,使用系统自定义Shape: 效果图: 1.默认状态 2.选中状态 实现分析: 1.目录结构: 代码实现: 1.button_normal.xml <?xml versi ...
- HDU 5688 Problem D
Problem D Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 【Jenkins】linux下Jenkins集成ant进行编译并发送结果
三个文章吧: 1 如何使用ant编译执行jmeter测试用例,并生成html报告 2 如何在Linux下搭建jenkins环境. 3 如何在Linux下搭建的jenkins中执行ant构建运行,并发送 ...
- HDU 5534 Partial Tree 完全背包
一棵树一共有2*(n-1)度,现在的任务就是将这些度分配到n个节点,使这n个节点的权值和最大. 思路:因为这是一棵树,所以每个节点的度数都是大于1的,所以事先给每个节点分配一度,答案 ans=f[1] ...
- rpi good tutorial
http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/quick-start/