2

I am pretty new to AngularJS. My question is regarding Hiding paramters in URL.

For Example, i have an URL Like,

http://localhost:8080/CareerTurn/#/viewExamwiseStudentsReport?exam_id=2&eName=College%20Model%20Exam&mMarks=10&time=00:10

I want to show this like,

http://localhost:8080/CareerTurn/#/viewExamwiseStudentsReport

HTML:

<a href="#viewExamwiseStudentsReport?exam_id={{exa.model_exam_id}}&eName={{exa.model_exam_name}}&mMarks={{exa.model_exam_total_marks}}&time={{exa.model_exam_duration}}">

I don't want to show parameters in URL but i want to use them in my JS Controller,

How to achieve it?

3
  • 1
    are you using ui-route or ng-route Commented Mar 30, 2017 at 7:13
  • 3
    Possible duplicate of How to remove GET params with AngularJS? Commented Mar 30, 2017 at 7:16
  • 1
    @sachilaranawaka ng-route.. have any better opinion or suggestion Commented Mar 30, 2017 at 13:01

1 Answer 1

0

You can use

$location.url($location.path());

Also

If you want to remove ALL query parameters, do:

$location.search({});

If you want To remove ONE particular query parameter, do:

$location.search('ParamName', null);
Sign up to request clarification or add additional context in comments.

2 Comments

what if im using like this in a HTMl page <a href="#viewExamwiseStudentsReport?exam_id={{exa.model_exam_id}}&eName={{exa.model_exam_name}}&mMarks={{exa.model_exam_total_marks}}&time={{exa.model_exam_duration}}"><button type="button" class="btn btn-primary btn-sm">View</button></a>
by using your code, all $routeParams are showing undefined. i dont want them in URL but i want to use them in my JS file

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.