angularjs - How to get the parent and child ids from location -
in url have id's this:
http://localhost:3000/#/projectsummary/2/3?id
from need both 2
(parent id) , 3 (child id) using $location.search
how both seperately. because need request 2 seperate query here.
at present using :
console.log( $location.search('id') );
it giving me :
{$$protocol: "http", $$host: "localhost", $$port: 3000, $$path: "/projectsummary/2/3", $$search: object…}$$absurl: "http://localhost:3000/#/projectsummary/2/3?id"$$compose: ()$$hash: ""$$host: "localhost"$$parse: (d)$$parselinkurl: (a,c)$$path: "/projectsummary/2/3"$$port: 3000$$protocol: "http"$$replace: false$$search: object$$state: null$$url: "/projectsummary/2/3?id"
from how can both id's 2
, 3
?
angular
$location.search()
output id
now have id
separate, lets other values...
$location.path()
output /#/projectsummary/2/3
now can this: $location.path().replace("/#/projectsummary/", "");
should give 2/3
but want this: $location.path().replace("/#/projectsummary/", "").split("/");
giving array of separate values.
now 3 values separated , ready put next string.
pure js
you need work javascript's location object.
window.location.search
output id
now have id
separate, lets other values...
window.location.pathname
output /#/projectsummary/2/3
now can this: window.location.pathname.replace("/#/projectsummary/", "");
should give 2/3
but want this: window.location.pathname.replace("/#/projectsummary/", "").split("/");
giving array of separate values.
now 3 values separated , ready put next string.
Comments
Post a Comment