UNPKG

knowhow-server

Version:

A personal workflow engine that can manage and use any network connected host

41 lines (40 loc) 1.92 kB
<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/cacheFactory.js#L196" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/cacheFactory.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">$templateCache</code> <div><span class="hint">service in module <code ng:non-bindable="">ng</code> </span> </div> </h1> <div><h2 id="description">Description</h2> <div class="description"><div class="ng-templatecache-page"><p>The first time a template is used, it is loaded in the template cache for quick retrieval. You can load templates directly into the cache in a <code>script</code> tag, or by consuming the <code>$templateCache</code> service directly.</p> <p>Adding via the <code>script</code> tag: <pre class="prettyprint linenums"> &lt;html ng-app&gt; &lt;head&gt; &lt;script type="text/ng-template" id="templateId.html"&gt; This is the content of the template &lt;/script&gt; &lt;/head&gt; ... &lt;/html&gt; </pre> <p><strong>Note:</strong> the <code>script</code> tag containing the template does not need to be included in the <code>head</code> of the document, but it must be below the <code>ng-app</code> definition.</p> <p>Adding via the $templateCache service:</p> <pre class="prettyprint linenums"> var myApp = angular.module('myApp', []); myApp.run(function($templateCache) { $templateCache.put('templateId.html', 'This is the content of the template'); }); </pre> <p>To retrieve the template later, simply use it in your HTML: <pre class="prettyprint linenums"> &lt;div ng-include=" 'templateId.html' "&gt;&lt;/div&gt; </pre> <p>or get it via Javascript: <pre class="prettyprint linenums"> $templateCache.get('templateId.html') </pre> <p>See <a href="api/ng.$cacheFactory"><code>$cacheFactory</code></a>.</p> </div></div> </div>