aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/cacheFactory.js
diff options
context:
space:
mode:
authorSpencer2013-07-17 09:45:53 -0500
committerPete Bacon Darwin2013-07-17 16:41:09 +0100
commitadd43e91dc8b766d52c9e8ccfe788efec17a94aa (patch)
treec7f030a61063ba451731a5893e3fe7ed19ce2b74 /src/ng/cacheFactory.js
parentb3c7a6d5664f8c95f7de0779dc54f23d2809f30c (diff)
downloadangular.js-add43e91dc8b766d52c9e8ccfe788efec17a94aa.tar.bz2
docs($templateCache): add examples of usage
Diffstat (limited to 'src/ng/cacheFactory.js')
-rw-r--r--src/ng/cacheFactory.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js
index 39fa7d89..f9ad8354 100644
--- a/src/ng/cacheFactory.js
+++ b/src/ng/cacheFactory.js
@@ -192,8 +192,44 @@ function $CacheFactoryProvider() {
* @name ng.$templateCache
*
* @description
- * Cache used for storing html templates.
- *
+ * The first time a template is used, it is loaded in the tempalte cache for quick retrieval. You can
+ * load templates directly into the cache in a `script` tag, or by consuming the `$templateCache`
+ * service directly.
+ *
+ * Adding via the `script` tag:
+ * <pre>
+ * <html ng-app>
+ * <head>
+ * <script type="text/ng-template" id="templateId.html">
+ * This is the content of the template
+ * </script>
+ * </head>
+ * ...
+ * </html>
+ * </pre>
+ *
+ * **Note:** the `script` tag containing the template does not need to be included in the `head` of the document, but
+ * it must be below the `ng-app` definition.
+ *
+ * Adding via the $templateCache service:
+ *
+ * <pre>
+ * var myApp = angular.module('myApp', []);
+ * myApp.run(function($templateCache) {
+ * $templateCache.put('templateId.html', 'This is the content of the template');
+ * });
+ * </pre>
+ *
+ * To retrieve the template later, simply use it in your HTML:
+ * <pre>
+ * <div ng-include=" 'templateId.html' "></div>
+ * </pre>
+ *
+ * or get it via Javascript:
+ * <pre>
+ * $templateCache.get('templateId.html')
+ * </pre>
+ *
* See {@link ng.$cacheFactory $cacheFactory}.
*
*/