Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit add43e9

Browse files
Spencerpetebacondarwin
Spencer
authored andcommittedJul 17, 2013
docs($templateCache): add examples of usage
1 parent b3c7a6d commit add43e9

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed
 

‎src/ng/cacheFactory.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,44 @@ function $CacheFactoryProvider() {
192192
* @name ng.$templateCache
193193
*
194194
* @description
195-
* Cache used for storing html templates.
196-
*
195+
* The first time a template is used, it is loaded in the tempalte cache for quick retrieval. You can
196+
* load templates directly into the cache in a `script` tag, or by consuming the `$templateCache`
197+
* service directly.
198+
*
199+
* Adding via the `script` tag:
200+
* <pre>
201+
* <html ng-app>
202+
* <head>
203+
* <script type="text/ng-template" id="templateId.html">
204+
* This is the content of the template
205+
* </script>
206+
* </head>
207+
* ...
208+
* </html>
209+
* </pre>
210+
*
211+
* **Note:** the `script` tag containing the template does not need to be included in the `head` of the document, but
212+
* it must be below the `ng-app` definition.
213+
*
214+
* Adding via the $templateCache service:
215+
*
216+
* <pre>
217+
* var myApp = angular.module('myApp', []);
218+
* myApp.run(function($templateCache) {
219+
* $templateCache.put('templateId.html', 'This is the content of the template');
220+
* });
221+
* </pre>
222+
*
223+
* To retrieve the template later, simply use it in your HTML:
224+
* <pre>
225+
* <div ng-include=" 'templateId.html' "></div>
226+
* </pre>
227+
*
228+
* or get it via Javascript:
229+
* <pre>
230+
* $templateCache.get('templateId.html')
231+
* </pre>
232+
*
197233
* See {@link ng.$cacheFactory $cacheFactory}.
198234
*
199235
*/

0 commit comments

Comments
 (0)
This repository has been archived.