【发布时间】:2018-07-18 00:47:09
【问题描述】:
我正在使用 angularJS 进行个人项目。我在线下载了这个 html 模板,当我测试该模板时,它运行良好。问题是,当我尝试使用 ng-include 将模板中的页面包含到我的项目中时,没有任何反应,没有错误,但也没有显示任何内容,只是一个空白页面。 基本上我的项目结构如下:
src > app > template > index.html(这是模板主页的位置)。
src > app > components > home > home.component.html(我项目的主页)
基本上我想在 home.component.html 中包含 index.html,但是 ng-include 不起作用:/
这是我在 home.component.html 中的代码:
<div ng-app = "" ng-controller = "homeController">
<div ng-include = "'/app/template/index.html'"> </div>
</div>
非常感谢:)
【问题讨论】:
-
您是否在控制台工具的网络选项卡上收到错误消息?我希望它正在尝试找到您的文件,但没有在
ng-include位置找到它。看起来您的包含在app/trueshoes中查找,但在您的问题中,您说index.html在app/template中。 -
哦,对不起,我刚刚意识到,这只是一个错字,它是 /app/template/index.html,我在我的问题中更正了它
-
我在控制台上没有任何错误
-
您是否在 html 中包含角度源文件并且它们是否正确加载?您可以在控制器中执行
console.log()吗?
标签: html angularjs angularjs-ng-include html-templates