Reputation: 49873
I have an url like this:
site.co/asd#antani?id=9
How do i get id
value from this url dynamically and get the new value when it changes?
i tryed :
console.log($routeParams);
and i got Object {}
in console
thanks
Upvotes: 5
Views: 3054
Reputation: 4159
Got a gist to do that and other useful functions on urls with params ( URL params to object, Test if url Has Params, get Hash without params, and Change url params)
https://gist.github.com/dazzer13/10470514
You can do this:
var params = urlGetParams(url);
params.id // returns 9
Upvotes: 1
Reputation: 49873
OK i think i fixed it and it was to change URL
so to make $routeParams
works i needed to call
site.com/asd?id=9#antani
instead of
site.co/asd#antani?id=9
hope it can help also if i don't like the url in that way :D
big thanks to all and if you have any better solution let me know please !
Upvotes: 2
Reputation: 77920
Since I don't know your full Env. I would go to this dirtection:
var s = $location.search('site.co/asd#antani?id=9');
console.log(s.$$search);
Output:
Object {site.co/asd#antani?id: "9"}
Hope it will help,
Upvotes: 2
Reputation: 3727
Assuming this is the actual page you are on, you can use angular $routeParams. Something like this:
var id = $routeParams.id
Upvotes: 0
Reputation: 7070
var myURL = "site.co/asd#antani?id=9";
var myURL_id = myURL.split("#")[1];
Upvotes: 0