angular.js得到URL斜杠分隔路径 [英] angular.js get slash-separated path from url
问题描述
我需要在我的网站的URL的文件路径(这将包含/字符一定数量)的参数。我怎样才能解析从URL这样的参数?类似的http://本地主机/路径/要/文件
将是preferable,但如果不工作, HTTP:/ /本地主机/?路径= /路径/要/文件
或事情就可以正常工作。
I need to take as a parameter in my site's urls a file path (that will contain some number of '/' characters). How can I parse such a parameter from a url? Something like http://localhost/path/to/file
would be preferable, but if that doesn't work, http://localhost/?path=/path/to/file
or something could work as well.
推荐答案
要在你的控制器使用的位置。第一个回合html5mode真像这样
to use location in your controller. first turn html5mode to true like this
然后你可以使用
location.search它将返回字符串没有任何错误。
更多的使用地点的去这里 https://docs.angularjs.org/api/ng/service / $位置
Then you can use location.search and it will return string without any error. for more use of location go here https://docs.angularjs.org/api/ng/service/$location
这篇关于angular.js得到URL斜杠分隔路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!