Question

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

Was it helpful?

Solution 2

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 !

OTHER TIPS

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,

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

var myURL = "site.co/asd#antani?id=9";
var myURL_id = myURL.split("#")[1];

Assuming this is the actual page you are on, you can use angular $routeParams. Something like this:

var id = $routeParams.id
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top