When working with Angular 7, I encountered a situation where I needed to pass a value from the service class of Angular. Here is how I achieved it:
executeHelloWorldBeanServiceWithPathVariable(name){
console.log("name coming from here"+name);
return this.httpClient.get<HelloWorldBean>('http://localhost:8080/hello-world/path-variable/${name}');
console.log("hello world bean service executed");
}
After testing, I confirmed that the name was successfully printed in the console as expected:
console.log("name coming from here"+name);
There were no issues with printing the name in the console.
https://i.stack.imgur.com/bHr3A.png
In my Spring Boot application, I defined the endpoint as follows:
@GetMapping(path="/hello-world/path-variable/{name}")
public HelloWorldBean helloWorldBeanPathVariable(@PathVariable("name") String name) {
System.out.print("name is"+name);
return new HelloWorldBean(String.format("Hello world %s", name));
}
However, when trying to print the passed parameter in the Spring Boot application using
System.out.print("name is"+name);
, I faced some difficulties as the name was not being displayed in the console as expected.
This issue led me to explore further and check how the name would appear through EL expressions instead:
https://i.stack.imgur.com/QcKcE.png
Ultimately, despite the debugging challenges, the UI output showed the correct result: