$location.host()

host();

This method is getter only.

Return host of current url.

Note: compared to the non-angular version location.host which returns hostname:port, this returns the hostname portion only.

// given url http://example.com/#/some/path?foo=bar&baz=xoxo
var host = $location.host();
// => "example.com"

// given url http://user:password@example.com:8080/#/some/path?foo=bar&baz=xoxo
host = $location.host();
// => "example.com"
host = location.host;
// => "example.com:8080"

Returns

string

host of current url.

doc_AngularJS
2016-03-29 16:10:29
Comments
Leave a Comment

Please login to continue.