[AngularJS] Taking control of your templates using $templateCache
of Using angularjs your Control templates
2023-09-14 09:00:55 时间
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') } })
相关文章
- 问题-Delphi 中使用TStringList后,报out of memory 的解决方法
- how to get geometry type of layer using IMapServer3 and IMapLayerInfo? (C#)
- [HTML5] Show Different Variations of Images Depending on the Viewport Width using Art Direction
- [TypeScript] Asynchronous Iteration using for-await-of
- [React Native] Animate the Scale of a React Native Button using Animated.spring
- [CSS] Target Positional Elements Using *-Of-Type CSS pseudo-classes
- (LeetCode 160)Intersection of Two Linked Lists
- [Docker] Benefits of Multi-stage Builds
- [Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method
- [JS Compse] 4. A collection of Either examples compared to imperative code
- [CSS] Target Positional Elements Using *-Of-Type CSS pseudo-classes
- what is the location of js when using run as server in Eclipse
- 【66.47%】【codeforces 556B】Case of Fake Numbers
- 成功解决A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,co
- inconsistent use of tabs and spaces in indentation
- 3GPP TS 29244-g30 中英文对照 | 5.3.5Forwarding of user data using Control Plane CIoT 5GS Optimisation
- 【Leetcode】Length of Last Word
- Accurate prediction of molecular targets using a self-supervised image rep...(论文解读)
- 论文阅读:CSPNET: A NEW BACKBONE THAT CAN ENHANCE LEARNING CAPABILITY OF CNN