What Is The Difference Between $location.path(redirecturl) And $location.url(redirecturl)?
I am talking about the setter methods for both and not the getter method For me $location.url doesnt always takes a while to redirect so i was thinking of using $location.path but
Solution 1:
The difference is in the getter of the $location.url() and the $location.path()
The url() getter returns path, search and hash in the form of /path?search=a&b=c#hash , while as path() will only return /path.
In terms of redirection, if it is only to a path, then yes I would use
$location.path(redirectpath).
You can read more about at $location docs
Solution 2:
Basically, path returns only the path but url also returns possible search or other parameters.
Check out the examples from the docs:
$location.path:
// given url http://example.com/#/some/path?foo=bar&baz=xoxo
var path = $location.path();
// => "/some/path"$location.url:
// given url http://example.com/#/some/path?foo=bar&baz=xoxo
var url = $location.url();
// => "/some/path?foo=bar&baz=xoxo"Solution 3:
path is only part of url that doesn't include search and hash
See examples in $location docs
Post a Comment for "What Is The Difference Between $location.path(redirecturl) And $location.url(redirecturl)?"