我试图包含一个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)。
相似问题