[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 ...
随机推荐
- php 对象的执行
1.BNF范式 %token T_OBJECT_OPERATOR "-> (T_OBJECT_OPERATOR)" unticked_statement: | expr TS ...
- NET SCADA软件简介
Scada是一款采用.Net WPF开发的免费组态软件,功能强大,支持服务器客户端方式运行.支持浏览器运行,软件非常小巧,免安装,支持Modbus和OPC通讯协议, 开放构架,支持C#.Net脚本,J ...
- CodeForces Round #286 Div.2
A. Mr. Kitayuta's Gift (枚举) 题意: 给一个长度不超过10的串,问能否通过插入一个字符使得新串成为回文串. 分析: 因为所给的串很多,所以可以枚举 “在哪插入” 和 “插入什 ...
- ORACLE DATAGURARD 折腾记二
前文再续,书接上一回,这次折腾Data Guard的一个重要目的是利用switchover实现机器的升级,怎么switchover呢?按照我的理解,Data Guard的角色切换是这样一个过程: (1 ...
- 【转】蓝牙ble app开发(三) -- 抓包
原文网址:http://blog.csdn.net/lckj686/article/details/43156617 关于android 蓝牙app开发抓包的重要性在 android 蓝牙ble ap ...
- vtiger 支持 物业收费功能 微信收费
谁要?需要什么功能? 直接在下面留言,博主会整理大家的需求,形成产品,发出来.
- openCV学习笔记
学习新玩意儿的事情,必须要懂人家的规矩,openCV就有自己的规范和数据结构的,要用人家的那些库函数,必须要把传入参数的基础结构搞搞明白,比如RGBA,人家opencv已经说了,用CvScalar,就 ...
- Cloudera Manager安装
安装环境: 系统:CentOS 6.3 64位 虚拟机:VMWare
- js基础第四天
多个tab栏切换class封装 <style> *{margin:0;padding:0;} ul{list-style:none;} .b ...
- LeetCode题解——Two Sum
题目地址:https://oj.leetcode.com/problems/two-sum/ Two Sum Given an array of integers, find two numbers ...