如何从angular $ location获取host + base

时间:2015-09-08 18:13:13

标签: angularjs

我的角度应用程序位于目录&some; someApp'。对于某些状态网址,网址为http://example-domain/someApp/#/的网址为http://example-domain/someApp/#/user/loginhttp://example-domain/someApp/。我在那里"棱角分明的方式"得到这个部分var redirectUri = $location.absUrl(); redirectUri = redirectUri.substr(0, redirectUri.indexOf('#'));

RecyclerView.Adapter.notifyItemChanged(int position)

1 个答案:

答案 0 :(得分:4)

您需要使用:

 location.origin + location.pathname

说网址是http://example.com/#/some/path?foo=bar&baz=xoxo

$location.protocol(); // will give: http
$location.host();     // will give: example.com
location.host         // will give: example.com:8080
$location.port();     // will give: 8080
$location.path();     // will give: /some/path
$location.url();      // will give: /some/path?foo=bar&baz=xoxo

查看完整的detail