gpt4 book ai didi

javascript - 将 ng-include 与 IIS 一起使用

转载 作者:行者123 更新时间:2023-11-28 07:08:53 25 4
gpt4 key购买 nike

以下 ng-include 标记适用于开发人员框,但不适用于 IIS 网站,因为它在输出中不包含网站名称。

<div ng-include="'/app/feature/list.html'" />

在运行 IISExpress 的开发人员计算机上,这会构建一个 url:http://localhost:49716/app/feature/list.html并且效果很好。

部署到 IIS 时,URL 为:http://server/app/feature/list.html 。这不起作用,因为该站点已被指定名称并在/site 上提供服务。预期的网址是 http://server/site/app/feature/list.html 。这会导致 404 错误和损坏的站点。

Angular 不应该能够构建相对于站点本身的真实路径吗?有没有办法让 Angular 做到这一点,而无需将其作为配置注入(inject)?

最佳答案

我的问题是网址中的斜线。斜杠表示绝对路径而不是相对路径。这个 ng-include 有效:

<div ng-include="'app/feature/list.html'" />

关于javascript - 将 ng-include 与 IIS 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31476541/

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