From 1a8d83d6608f7c29116e4dc9dd565df21a4ae045 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 17 Jul 2013 09:45:53 -0500 Subject: [PATCH] docs($templateCache): add examples of usage --- src/ng/cacheFactory.js | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js index fb4c2c6b8165..a00c09a655a8 100644 --- a/src/ng/cacheFactory.js +++ b/src/ng/cacheFactory.js @@ -194,8 +194,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: + *
+ * 
+ * 
+ * 
+ * 
+ *   ...
+ * 
+ * 
+ * + * **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: + * + *
+ * var myApp = angular.module('myApp', []);
+ * myApp.run(function($templateCache) {
+ *   $templateCache.put('templateId.html', 'This is the content of the template');
+ * });
+ * 
+ * + * To retrieve the template later, simply use it in your HTML: + *
+ * 
+ *
+ * + * or get it via Javascript: + *
+ * $templateCache.get('templateId.html')
+ * 
+ * * See {@link ng.$cacheFactory $cacheFactory}. * */