gpt4 book ai didi

angularjs - 是否可以在没有 Web 服务器的情况下使用 ng-include?

转载 作者:行者123 更新时间:2023-12-03 14:29:33 26 4
gpt4 key购买 nike

我正在运行一个 AngularJS 应用程序,它只包含一个文件

<div ng-include src="'sample.html'"></div>

这在 web 服务器下运行时有效。但是,如果仅通过从文件资源管理器(即不是从 Web 服务器)双击运行 Web 应用程序,则它不包含该文件

ng-include 是否在 Web 服务器之外工作?我检查了 Chrome 上的网络状态,显示 选项 关于方法,和 负载取消 状态

最佳答案

一种解决方法是内联您的模板:

<script type="text/ng-template" id="sample.html">
<div>This is my sample template</div>
</script>

Fiddle .

这会将您的模板放入 Angular 的模板缓存中。当处理 ng-include 指令时,Angular 首先检查缓存。

关于angularjs - 是否可以在没有 Web 服务器的情况下使用 ng-include?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14420337/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com