[AngularJS] Taking control of your templates using $templateCache
2015-03-07 17:23
316 查看
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")
or you can but your template in the <script> tag, then use templateCache.get() method:
$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') } })
相关文章推荐
- django1.8 提示(1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your defau
- 每日一读 TidBITS.Take.Control.of.Your.Paperless.Office
- Using your laptop to compute PageRank for millions of webpages
- Using the Events Manager of the InfoPath Hosted Control
- Error 7043: Load control template file /_controltemplates/TaxonomyPicker.ascx failed
- Working with Data in ASP.NET 2.0 :: Using TemplateFields in the GridView Control
- webpack打包vue2.0,[Vue warn]: You are using the runtime-only build of Vue where the template compiler
- Using Templates With the ASP.NET Repeater Control...
- The run order about Loaded event and OnApplyTemplate in custom control of Silverlight 2 beta 2
- Building a Mashup of National Parks using the Atlas Virtual Earth Map control
- Using the multiple NICs of your File Server running Windows Server 2008 (and 2008 R2)
- 23 In Recovery Manager (RMAN), you are taking image copies of the data files of your production data
- Using freewheel.labs.autodesk.com to auto generate preview images of DWF files on your web site
- angularjs禁用template cache
- Question 5: Which of the following statements regarding the benefits of using template functions over preprocessor #define macro
- how to write your annotation types and make use of built-in annotations to control their behavior
- Building a Mashup of National Parks using the Atlas Virtual Earth Map control
- Take Ownership of Your Actionsby Taking Responsibility--让责任心去支配你的行动
- C# Meta Programming - Let Your Code Generate Code - Introduction of The Text Template Transformation Toolkit(T4)
- Embed an HTML control in your own window using plain C