?
This document uses PHP Chinese website manual Release
載入<script>
元素內(nèi)容到$templateCache
,這樣模板就能通過(guò)ngInclude
和 ngView
,或directives來(lái)使用。 <script>
元素的類型必須設(shè)定為text/ng-template
,并且必須通過(guò)元素的id
來(lái)給出模板的緩沖名稱,這樣就能用于指令的templateUrl
了。
<script
Type=""
id="">...</script>
參數(shù) | 類型 | 詳述 |
---|---|---|
Type | string | 必須設(shè)為 |
id | string | 模板的緩沖名稱。 |
<script Type="text/ng-template" id="/tpl.html">
Content of the template.
</script>
<a ng-click="currentTpl='/tpl.html'" id="tpl-link">Load inlined template</a>
<div id="tpl-content" ng-include src="currentTpl"></div>
it('should load template defined inside script tag', Function() {
element(by.css('#tpl-link')).click();
expect(element(by.css('#tpl-content')).getText()).toMatch(/Content of the template/);});