0

I have a controller that returns jsp page. So how can I make request from angularjs and display that page in browser?

Controller:

@RequestMapping("user/{username}")
public String showUserDetails(@PathVariable String username, Model model) throws SQLException {
    model.addAttribute("userDetails",dbHelper.getUser(username));
    return "/profile.jsp";
}

Angularjs:

$scope.openProfile = function(username){

        $http.get("/root/services/rest/user/" + username);

    }

When I call this function from jsp, I get jsp page in response, but it is not being displayed in browser.

1 Answer 1

1

Controller will return the string of url or view name then you can change url via $location or $window other wise your can also use ui-view or ng-view for the change view/route.

Sign up to request clarification or add additional context in comments.

2 Comments

But $location.path only adds up to existing url, and doesn't refresh the page.
use $state.transitionTo with reload

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.