©
Dokumen ini menggunakanManual laman web PHP CinaLepaskan
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 ascript
tag, or by consuming the$templateCache
service directly.
Adding via thescript
tag:
注意:thescript
tag containing the template does not need to be included in thehead
of the document, but it must be below theng-app
definition.
Adding via the $templateCache service:
varmyApp=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:
ng-include=" 'templateId.html' ">
or get it via Javascript:
$templateCache.get('templateId.html')
参见 $cacheFactory.