[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 ...
随机推荐
- createSQLQuery与createQuery的区别
本文原址 : http://stta04.javaeye.com/blog/377633hibernate 中createQuery与createSQLQuery 昨晚帮同事看代码到凌晨2点多,今早6 ...
- UPC 2224 Boring Counting ★(山东省第四届ACM程序设计竞赛 tag:线段树)
[题意]给定一个长度为N的数列,M个询问区间[L,R]内大于等于A小于等于B的数的个数. [题目链接]http://acm.upc.edu.cn/problem.php?id=2224 省赛的时候脑抽 ...
- Oracle 参数化更新数据时报错:Oracle ORA-01722: 无效数字
报错:Oracle ORA-01722: 无效数字 看了一篇博客,据说是参数与列名不能一致,改过之后还是报一样的错误:Oracle ORA-01722: 无效数字 ,后来试了一下,不是参数名必须不一样 ...
- mysql 交叉表
交叉表,但在MySQL中却没有这个功能,但网上看到有不少朋友想找出一个解决方法,特发贴集思广义.http://topic.csdn.net/u/20090530/23/0b782674-4b0b-4c ...
- 本地连接图标消失;修改地址IP地址
(1)网络连接中没有本地连接,电脑无法进行拨号.无法上网,右键点击“网上连接”选择“属性”,弹出的“网络连接”文件夹中没有本地连接的图标,类似情况处理起来要相对复杂些了,我们逐一判断故障原因,在想办法 ...
- Java + Excel 接口自动化
最近项目比较悠闲,想找点事干,写了个 Excel 接口测试的 "框架" 以前用 python 写过一个,这次用 java, 应该说框架都不算,反正就是写了,能帮我解决问题就行. 当 ...
- 对单片机的modbus RTU的详细解释(转载)
Modbus 一个工业上常用的通讯协议.一种通讯约定.Modbus协议包括RTU.ASCII.TCP.其中MODBUS-RTU最常用,比较简单,在单片机上很容易实现.虽然RTU比较简单,但是看协议资料 ...
- Magento 重新安装的方法
如果之前已经成功安装Magento, 不必再下载Magento进行重新安装,很多朋友删掉所有程序文件然后再上传一个magento程序包进行重新安 装, 这样做很耗时间. 其实只需把magento的根目 ...
- KNN及其改进算法的python实现
一. 马氏距离 我们熟悉的欧氏距离虽然很有用,但也有明显的缺点.它将样品的不同属性(即各指标或各变量)之间的差别等同看待,这一点有时不能满足实际要求.例如,在教育研究中,经常遇到对人的分析和判别,个体 ...
- 2.3CUDA矩阵乘法
CPU 矩阵乘法 能相乘的两个矩阵,必须满足一个矩阵的行数和第二个矩阵的列数相同. A(N*P) * B(P*M) = C(N*M). 其中P是行数,N是列数, 从宽高的角度来说,即 A的宽度和B的高 ...