AngularJS 2路由 [英] AngularJS 2 routing

查看:158
本文介绍了AngularJS 2路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5 PushState 表示刷新网址或在浏览器中输入直接网址,当我使用'npm start'运行我的角度应用时,效果非常好来自VS 2015命令提示符的code>命令。但是,当我在IIS上部署相同的应用程序并将< base href =//> 更改为< base href =/ MyVirtualApplication / /> 然后 HTML5的PushState 历史记录API 无法正常工作并引发404错误。

HTML5 PushState means refresh URL or enter direct URL in browser works perfectly fine when I run my angular app using 'npm start' command from VS 2015 command prompt. However when I deploy same application on IIS and change <base href="/"/> to <base href="/MyVirtualApplication/" /> then HTML5's PushState or History API doesn't work properly and raising 404 error.

请建议。

推荐答案

我认为我在对nodejs的基本了解及其使用后得到了我的答案与Angular2。

I Think I got my answer after basic understanding on nodejs and use of it with Angular2.

基本上,nodejs - expressjs本身就是一个Web服务器,当我们执行命令时,npm start web server启动并列出定义的端口。它不需要任何额外的服务器。

Basically, nodejs - expressjs itself is a web server and when we execute a command npm start web server starts and listing on a port which is defined. And it does not require any additional server.

这篇关于AngularJS 2路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆