角度$location.如果用户提交带有hashbang的URL,如何在html5Mode(true)中解析查询字符串
Angular $location. How could be parsed a query string in html5Mode(true) if user submit an URL with hashbang?
我正在开发一个搜索页面,并要求将所有选定的筛选器和其他状态存储在URL中,以便用户可以共享他们的工作结果。
我使用angular$location.search()来更新和解析URL。位置提供商设置如下:
$locationProvider.html5Mode(true).hashPrefix('!');
当传统浏览器的用户与现代浏览器的用户共享带有hashbang的链接时,问题就开始了。在这种情况下,$location.search()将不返回任何内容。
据我所知,原因是在"#"启动$location.hash()而不是$location.search()之后的html5模式中。但是hashPrefix('!')的目标是什么?我认为它应该解决这样的问题。。。
如果用户提交了带有hashbang的URL,我如何在html5Mode(true)中解析查询字符串?
好吧,如果您将html5Mode设置为true,它将处理Angular中的所有路由,但它不会反映服务器如何路由到您的应用程序。你现在可能已经为hashbangs设置了路由,但如果你也在服务器上提供了没有路由的路由呢?
据我所知,如果您将html5Mode设置为true,而传统浏览器不支持它,它将自动回退到哈希标记路由。如果有人捕获了该URL,然后与朋友共享,并且您的服务器上有支持,可以在任何一种情况下正确地将查询、路由和深度链接转换到您的Angular应用程序,那么您似乎都会受到保护。
相关文章:
- 如何在angularJS中编辑时,如果DB中的值为true,则设置复选框,如果值为false,则取消选中复选框
- AngularJS-使用'true'属性
- JavaScript-切换“;全部检查”;复选框true/false
- location.reload(true)崩溃浏览器选项卡
- 指令的模板必须只有一个根元素:With restrict E&替换true
- JavaScript:只有当数组中的所有项都为true时才执行函数
- 对于loop.if-仅在经过所有间隔后返回true
- if(foo!==null)的计算结果为true,即使foo为null
- ngIf的计算结果始终为true
- 如果函数返回True,则显示Javascript按钮
- (false==false==true)怎么可能是真的
- AngularJS URL使用$locationProvider.html5Mode进行了转义(true)
- 带有代码点火器的ui-router在刷新页面或使用html5mode(true)粘贴URL时给出404
- $locationProvider.html5Mode(true) 在 SPA Angularjs 中无法正常工作
- Angularjs html5Mode(true) 页面重新加载错误与 Node.js 服务器
- Angular.js html5mode(true)和普通锚点href链接
- $locationProvider.html5Mode(true)不能与tomcat一起工作
- 是否html5mode(true)影响谷歌搜索爬虫
- Angular - $locationProvider.html5Mode(true)会阻止routeProvider使
- 角度$location.如果用户提交带有hashbang的URL,如何在html5Mode(true)中解析查询字符串