How do I parse URL params after a hash with Angularjs?
From angular location service $location.hash()
method return #after-hash
so if your url is look like
https://mywebsite.com/4sqredirect/#access_token=1234567890XXXXX
then
$location.hash()
return access_token=1234567890XXXXX
you need to split it split('=')[1]
see this plunker when you click 4Square
then $location.url()
return
/4sqredirect/#access_token=123456$location.hash().split('=')[1]
return 123456
Use $location.search()
//e.g. url https://www.example.com/#!?name=123var s = $location.search();// {name: '123'}
http://docs.angularjs.org/api/ng.$location
Search:
Returns search part (as object) of current url when called without any parameter.
I'm not aware of a "native angular" way to do it, but you do have access to the hash via location.hash
as a string type. it's probably not ideal, but it's workable.