内にHTMLスニペットをインクルードしようとしてng-repeat
いますが、インクルードを機能させることができません。の現在の構文ng-include
は以前のものとは異なるようです。
<div ng-include src="path/file.html"></div>
しかし、公式のドキュメントでは、それは使用するように言っています
<div ng-include="path/file.html"></div>
しかし、ページの下には次のように表示されます
<div ng-include src="path/file.html"></div>
とにかく、やってみました
<div ng-include="views/sidepanel.html"></div>
<div ng-include src="views/sidepanel.html"></div>
<ng-include src="views/sidepanel.html"></ng-include>
<ng-include="views/sidepanel.html"></ng-include>
<ng:include src="views/sidepanel.html"></ng:include>
私のスニペットはあまりコードではありませんが、多くのことが起こっています。問題を引き起こす可能性のあるテンプレートを動的ng-repeat
に読み込むで読んだので、の内容をsidepanel.html
単語だけに置き換えましたがfoo
、それでも何もありません。
また、次のようにページで直接テンプレートを宣言してみました。
<script type="text/ng-template" id="tmpl">
foo
</script>
ng-include
そして、スクリプトを参照するすべてのバリエーションを実行しますがid
、それでも何もありません。
私のページにはもっとたくさんの情報が含まれていましたが、今ではこれだけにまとめました。
<!-- index.html -->
<html>
<head>
<!-- angular includes -->
</head>
<body ng-view="views/main.html"> <!-- view is actually set in the router -->
<!-- views/main.html -->
<header>
<h2>Blah</h2>
</header>
<article id="sidepanel">
<section class="panel"> <!-- will have ng-repeat="panel in panels" -->
<div ng-include src="views/sidepanel.html"></div>
</section>
</article>
<!-- index.html -->
</body>
</html>
ヘッダーはレンダリングされますが、テンプレートはレンダリングされません。コンソールまたはノードからエラーは発生しません。src="views/sidepanel.html"
開発ツールでリンクをクリックすると、テンプレートに移動します(そして表示されますfoo
)。