Spring Boot RestEndpoint Redirect to Angular Route
I have a cross domain page, From there i will be getting the parameters needed to load the Angular UI.
The idea for me is to call the spring boot rest end point and redirect to angular page with response.
The spring boot rest end point with @PathVariable parameters, This will query the database and get the response, Once the response is ready which has to be redirected to angular route with the response.
I have used RedirectView to redirect but i am unable to get hold of the parameters in the Angular side. Just wondering what would be the best approach to pass the data in spring boot and intercept that on Angular side.
spring angular spring-boot
add a comment |
I have a cross domain page, From there i will be getting the parameters needed to load the Angular UI.
The idea for me is to call the spring boot rest end point and redirect to angular page with response.
The spring boot rest end point with @PathVariable parameters, This will query the database and get the response, Once the response is ready which has to be redirected to angular route with the response.
I have used RedirectView to redirect but i am unable to get hold of the parameters in the Angular side. Just wondering what would be the best approach to pass the data in spring boot and intercept that on Angular side.
spring angular spring-boot
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
1
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55
add a comment |
I have a cross domain page, From there i will be getting the parameters needed to load the Angular UI.
The idea for me is to call the spring boot rest end point and redirect to angular page with response.
The spring boot rest end point with @PathVariable parameters, This will query the database and get the response, Once the response is ready which has to be redirected to angular route with the response.
I have used RedirectView to redirect but i am unable to get hold of the parameters in the Angular side. Just wondering what would be the best approach to pass the data in spring boot and intercept that on Angular side.
spring angular spring-boot
I have a cross domain page, From there i will be getting the parameters needed to load the Angular UI.
The idea for me is to call the spring boot rest end point and redirect to angular page with response.
The spring boot rest end point with @PathVariable parameters, This will query the database and get the response, Once the response is ready which has to be redirected to angular route with the response.
I have used RedirectView to redirect but i am unable to get hold of the parameters in the Angular side. Just wondering what would be the best approach to pass the data in spring boot and intercept that on Angular side.
spring angular spring-boot
spring angular spring-boot
edited Nov 14 '18 at 22:13
R. Richards
14.4k93742
14.4k93742
asked Nov 14 '18 at 22:03
JoeJoe
155
155
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
1
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55
add a comment |
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
1
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
1
1
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55
add a comment |
2 Answers
2
active
oldest
votes
Good practice to call the angular page first and use a route resolver to get the data from the rest API.
But in your case, you can redirect to an angular app from spring boot controller
return "redirect:" + yourDomain/param1/param2
And route resolver in an angular app URL like
url: "/endUrl/:param1/:param2"
Read that parameter in the controller from state param
add a comment |
Ok, I am able to achieve both with the combination of Spring boot Rest Endpoint and Angular Route Resolver.
@GetMapping(value = "/list/{param1}/{param2}")
public RedirectView redirectToHomePage(final RedirectAttributes attributes, @PathVariable final String param1,
@PathVariable final String param2)
{
return new RedirectView("/showlist/{param1}/{param2}", true);
}
On the Angular Side
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309403%2fspring-boot-restendpoint-redirect-to-angular-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Good practice to call the angular page first and use a route resolver to get the data from the rest API.
But in your case, you can redirect to an angular app from spring boot controller
return "redirect:" + yourDomain/param1/param2
And route resolver in an angular app URL like
url: "/endUrl/:param1/:param2"
Read that parameter in the controller from state param
add a comment |
Good practice to call the angular page first and use a route resolver to get the data from the rest API.
But in your case, you can redirect to an angular app from spring boot controller
return "redirect:" + yourDomain/param1/param2
And route resolver in an angular app URL like
url: "/endUrl/:param1/:param2"
Read that parameter in the controller from state param
add a comment |
Good practice to call the angular page first and use a route resolver to get the data from the rest API.
But in your case, you can redirect to an angular app from spring boot controller
return "redirect:" + yourDomain/param1/param2
And route resolver in an angular app URL like
url: "/endUrl/:param1/:param2"
Read that parameter in the controller from state param
Good practice to call the angular page first and use a route resolver to get the data from the rest API.
But in your case, you can redirect to an angular app from spring boot controller
return "redirect:" + yourDomain/param1/param2
And route resolver in an angular app URL like
url: "/endUrl/:param1/:param2"
Read that parameter in the controller from state param
edited Nov 15 '18 at 9:09
answered Nov 15 '18 at 8:54
Pranay KumbhalkarPranay Kumbhalkar
596417
596417
add a comment |
add a comment |
Ok, I am able to achieve both with the combination of Spring boot Rest Endpoint and Angular Route Resolver.
@GetMapping(value = "/list/{param1}/{param2}")
public RedirectView redirectToHomePage(final RedirectAttributes attributes, @PathVariable final String param1,
@PathVariable final String param2)
{
return new RedirectView("/showlist/{param1}/{param2}", true);
}
On the Angular Side
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
add a comment |
Ok, I am able to achieve both with the combination of Spring boot Rest Endpoint and Angular Route Resolver.
@GetMapping(value = "/list/{param1}/{param2}")
public RedirectView redirectToHomePage(final RedirectAttributes attributes, @PathVariable final String param1,
@PathVariable final String param2)
{
return new RedirectView("/showlist/{param1}/{param2}", true);
}
On the Angular Side
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
add a comment |
Ok, I am able to achieve both with the combination of Spring boot Rest Endpoint and Angular Route Resolver.
@GetMapping(value = "/list/{param1}/{param2}")
public RedirectView redirectToHomePage(final RedirectAttributes attributes, @PathVariable final String param1,
@PathVariable final String param2)
{
return new RedirectView("/showlist/{param1}/{param2}", true);
}
On the Angular Side
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
Ok, I am able to achieve both with the combination of Spring boot Rest Endpoint and Angular Route Resolver.
@GetMapping(value = "/list/{param1}/{param2}")
public RedirectView redirectToHomePage(final RedirectAttributes attributes, @PathVariable final String param1,
@PathVariable final String param2)
{
return new RedirectView("/showlist/{param1}/{param2}", true);
}
On the Angular Side
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
@Injectable()
export class ShowlistResolver implements Resolve<any> {
private data: UserData
constructor(private router: Router, private userService: UserService) {
this.userData = new UserData();
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
console.log('In Router')
this.userData.userId = route.params['id']
this.userData.userRole = route.params['role'];
this.userService.setUserData(this.userData);
this.router.navigate(['/showAll/list', {outlets: {details: ['showDetails']}}]);
}
answered Nov 15 '18 at 20:29
JoeJoe
155
155
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309403%2fspring-boot-restendpoint-redirect-to-angular-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
why don't you call the angular page first and use a route resolver to get the data from the rest api?
– Roddy of the Frozen Peas
Nov 14 '18 at 22:20
I need to pass the data from another application while clicking the hyperlink to spring+angular app.
– Joe
Nov 14 '18 at 23:16
1
Yes? So if your angular route is like example.com/product/16 then your resolver can do the data call while routing. (eg in the example, do the call to get the data for product with id 16.) That's what route resolvers are for.
– Roddy of the Frozen Peas
Nov 15 '18 at 0:16
Right now i am not that familiar on Route resolvers will check on that, however i am loading a route based on the incoming data, So based on my understanding, The other application will directly call the angular route url or construct the url dynamically, By which has the route resolver get the url and pass on to back end and render the page.Is that right?
– Joe
Nov 15 '18 at 0:55