Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b37e8a2

Browse files
committed
docs(directive.script): Add simple example of inlined template
1 parent 4c1c50f commit b37e8a2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/widgets.js

+26
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,32 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
781781
}];
782782

783783

784+
/**
785+
* @ngdoc widget
786+
* @name angular.module.ng.$compileProvider.directive.script
787+
*
788+
* @description
789+
* Load content of a script tag, with type `text/ng-template`, into `$templateCache`, so that the
790+
* template can be used by `ng:include` or `ng:view`.
791+
*
792+
* @example
793+
<doc:example>
794+
<doc:source>
795+
<script type="text/ng-template" id="/tpl.html">
796+
Content of the template.
797+
</script>
798+
799+
<a ng:click="currentTpl='/tpl.html'" id="tpl-link">Load inlined template</a>
800+
<div id="tpl-content" ng-include src="currentTpl"></div>
801+
</doc:source>
802+
<doc:scenario>
803+
it('should load template defined inside script tag', function() {
804+
element('#tpl-link').click();
805+
expect(element('#tpl-content').text()).toMatch(/Content of the template/);
806+
});
807+
</doc:scenario>
808+
</doc:example>
809+
*/
784810
var scriptTemplateLoader = ['$templateCache', function($templateCache) {
785811
return {
786812
terminal: true,

0 commit comments

Comments
 (0)