2

how do we get only the value from the router param map. right now the output is

 authkey:af408c30-d212-4efe-933d-54606709fa32

I only want the random "af408c30-d212-4efe-933d-54606709fa32" without the key "authkey:" how do we parse that in JavaScript ? or is there a way in angular to not include the key and just get the value. Thanks.

 this.router.paramMap.subscribe(paramMap => {
      this.authKey = paramMap.get('authkey')
    });
  • current output : authkey:af408c30-d212-4efe-933d-54606709fa32
  • desired output : af408c30-d212-4efe-933d-54606709fa32 , I want to exclude the authkey:.

2 Answers 2

2

You can just delete authKey from the retrieved string like so:

  this.authKey = paramMap.get('authkey').replace('authkey:', '')
Sign up to request clarification or add additional context in comments.

Comments

1

Angular is seeing everything as the authkey parameter. This is from the way you specify parameters in your Router Module. You should do some string manipulation to remove the "authkey:".

Do this:

this.authKey = paramMap.get('authkey').replace('authkey:', '')

1 Comment

suggestion : add code fences to highlight the code and make it better to read

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.