【问题标题】:hosting an angular 2 app in an application under localhost在 localhost 下的应用程序中托管 Angular 2 应用程序
【发布时间】:2017-01-01 12:35:11
【问题描述】:

我是 angular2 的初学者,并根据我找到的示例开始了一个项目。在 Windows 上托管我的应用程序时,它可以通过 http:/localhost(或使用 npm http://localhost:3000)访问,但如果我尝试将它放在 IIS 上的 localhost/MyApp 上,仍然会尝试在 localhost 下导航。

您可以在以下位置找到我使用的示例代码: https://github.com/DeborahK/Angular2-GettingStarted/tree/master/APM%20-%20Final

有什么简单的方法吗?

【问题讨论】:

  • 你设置默认页面了吗?
  • 是的。仍然发生

标签: angular iis


【解决方案1】:

试试这个:在你的 Angular 2 应用程序的 index.html 中,编辑 <base href="/MyApp/">。

【讨论】:

  • 这正是我想要的。我还必须在 system.js 配置中将该路径更改为 npm。
  • 还有一件事。现在我在代码中使用了 MyApp。 npm start 寻找 localhost:3000/Myapp 女巫不正确。我可以看到我的代码在 IIS 上运行,但我还能在节点上运行它吗?
  • 不知道您后续问题的答案。也许您可以使用 Angular cli 开发您的 Angular 2 应用程序,在 IIS 下服务之前,您只需运行 ng build --base-href /myUrl/。 github.com/angular/angular-cli#base-tag-handling-in-indexhtml
猜你喜欢
  • 2016-10-13
  • 1970-01-01
  • 2018-01-15
  • 2020-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-25
  • 2019-03-21
相关资源
最近更新 更多