mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
docs($templateCache): add examples of usage
This commit is contained in:
parent
b3c7a6d566
commit
add43e91dc
1 changed files with 38 additions and 2 deletions
|
|
@ -192,8 +192,44 @@ function $CacheFactoryProvider() {
|
||||||
* @name ng.$templateCache
|
* @name ng.$templateCache
|
||||||
*
|
*
|
||||||
* @description
|
* @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}.
|
* See {@link ng.$cacheFactory $cacheFactory}.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue