Angular js - get url request parameters when url has # hash

I have a url:

site.co/asd#antani?id=9

How do I get the value idfrom this url dynamically and get the new value when it changes?

I tried:

console.log($routeParams);and I got Object {}in the console

thank

+4
source share
5 answers

Ok i think i fixed it and it should have changed the url

so to do the $routeParamswork I had to call

site.com/asd?id=9#antani

instead

site.co/asd#antani?id=9

hope this helps too if I don't like the url this way: D

thank you very much everyone and if you have a better solution let me know please!

+2
source

Env. :

var s = $location.search('site.co/asd#antani?id=9');

console.log(s.$$search);

:

Object {site.co/asd#antani?id: "9"} 

, ,

+2

URL- (URL- , Test, url Params, Hash url)

https://gist.github.com/dazzer13/10470514

:

var params = urlGetParams (url);

params.id// 9

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

, , , angular $routeParams. - :

var id = $routeParams.id
0

Source: https://habr.com/ru/post/1535155/


All Articles