?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
載入<script>
元素內(nèi)容到$templateCache
,這樣模板就能通過ngInclude
和 ngView
,或directives來使用。 <script>
元素的類型必須設定為text/ng-template
,并且必須通過元素的id
來給出模板的緩沖名稱,這樣就能用于指令的templateUrl
了。
<script
Type=""
id="">...</script>
參數(shù) | 類型 | 詳述 |
---|---|---|
Type | string | 必須設為 |
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/);});