zouabimourad / angular2-spring

Angular 2+ and Spring Integration
130 stars 86 forks source link

Full CRUD Functionality #6

Closed rakshitshah94 closed 7 years ago

rakshitshah94 commented 7 years ago

Hello, You gave nice example to understand the integration with springboot, thank you. I am new to angular 2 and developing whole crud functionality with angular2 and springboot (I am following your reference), but facing some issues! screenshot 196

PFA, As shown in picture (I numbered 1,2,3. That I want to do), I want to add "Add/Create" and "Edit/Update" functionality as shown in picture.

Point 1. when i fill the form and click on add button, this json should be append to localhost:8080/api/person/ screenshot 197 PFA which is JSON on H2 Database.

On server side, I added value = "/" , is it correct ? In browser console I get "error_handler.js:47EXCEPTION: Response with status: 400 OK for URL: http://localhost:8080/api/person/NaN"

See my snippet> @RequestMapping(value = "/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public void createPerson(@RequestBody PersonDTO personDTO) { personService.savePerson(personDTO); }

Point 2 : On click "Edit button(Number 2 in picture)" it should fetch current values to the form(Number 3) and the button (Number 1 in picture)should be change accordingly (for example, if id exist then button value = "update" and if id not exist then button value = "add", is it possible to achieve ?)

Please tell me where I stucked and let me know possible solutions. I searched more about errors over internet but it did not work for me or I am going in wrong direction ! If you want to see updated source, please visit > https://github.com/rakshitshah94/Angular2-SpringBoot-Example.