启用 AngularJS HTML5 路由:将 URL 传递回服务器? [英] AngularJS HTML5 Routing Enabled : Passing URL Back to server?

查看:25
本文介绍了启用 AngularJS HTML5 路由:将 URL 传递回服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启用了 Html5Mode 的 AngularJS SPA.我从我的 URLS 中删除了哈希,除了一个问题外,一切都很好.我们的站点有下载链接,用于通过对 MVC 控制器方法的 HTTPGET 调用从服务器下载文档.Angular 不再将路由传递回服务器,因为它认为它需要处理它.我如何告诉 Angular 的路由引擎将 GET 传递回服务器?我曾考虑将下载切换到 WebAPI,但我使用这种方法读取了混合结果.

I have an AngularJS SPA with Html5Mode enabled. I removed the hashes from my URLS and everything works great except for one issue. Our site has download links for downloading documents from the server via a HTTPGET call to a MVC controller method. Angular no longer passes the route back to the server because it thinks it needs to handle it. How do I tell Angular's routing engine to pass the GET back to the server? I have considered switching the download to a WebAPI, but I read mixed results with this approach.

谢谢!

推荐答案

我想通了!:) 解决方案是将 target='_self' 添加到您的锚标记.任何其他目标值也适用;_blank"、_top"等.我在 IE 9、10 中对此进行了测试;Chrome 40-43、Opera 25-29 和 Safari 5.1

I figured it out! :) The solution is to add target='_self' to your anchor tag. Any of the other target values work too; "_blank", "_top" and so on. I tested this in IE 9, 10; Chrome 40-43, Opera 25-29, and Safari 5.1

这篇关于启用 AngularJS HTML5 路由:将 URL 传递回服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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