0

I'm migrating a JSP/Spring project to Angular JS 1.X. Currently I'm stuck in following situation, appreciate if anyone can help. My application is redirecting to a 3rd party app and after submitting a form response is coming back to again my application. In spring I used to get the request parameter using following code. How can I get the request parameters in Angular JS?

@Autowired
private HttpServletRequest request;
..
Enumeration paramsEnum = request.getParameterNames();
while (paramsEnum.hasMoreElements()) {
 String paramName = (String) paramsEnum.nextElement()
 ....
}
2

2 Answers 2

0

Not sure I understood the question because with Java/Spring we access the params sent by angularJS.

Anyway, If you want to access a Url parameters of the current view you can use the angularjs $location service:

$location.search()

For example taking the 'impersonate_token' from the url and adding it to some variable:

if($location.search().token){ 
    var token = $location.search().token; 
    url += "?impersonate_token=" +token; 
}

if you want to manage the Url parameters send to the server side, you can do with angularjs $http service like this:

    $http({
        url: your/url, 
        method: "GET",
        params: {
           param_1: $scope.some_data
           param_2: $scope.some_data2
        }
   });
Sign up to request clarification or add additional context in comments.

2 Comments

Question is not about sending request to server side. From a 3rd party application, a request is coming to my angular js application via URL call and I need to read those request parameter.
OK, so I think its option #1 in the Answer - an example was added.
0
  $http.get(url)
   .then(function(response) {
   $scope.myWelcome = response.data;
  });

1 Comment

Please explain why this answers the question. Dumping code doesn't help future users :)

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.