0

I'am trying to get paramter from url like that:

index.html#!/forum/page?1-something

the number that what i'am trying to get

both $location.url(); and $location.absUrl(); get the whole url

do I have to use split and how to do that?

1
  • No, what's after the # is the hash Commented Mar 18, 2020 at 18:09

1 Answer 1

1

Using $location.search() you can get all query parameters. by iterating an object you can get all key and value as well.

I used to iterate object using for-in loop. here $location.search() is an object itself so you can iterate it as:

for(let key in $location.search()){
   console.log("key: "+key+" value: "+$location.search()[key]);
} 

we can also append query parameters using $location.search() by just passing parameters to it. this can be done as:

let obj = {site:'stack overflow', exp: 'happy coding'}

and this obj object can be passed to $location.search() as:

$location.search(obj);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.