Return generated id

-1

I'm using Angular 6+ and springboot. How do I generate an id and retrieve it?

ex: I have the following page:

Whentheuserclickson"New" will make a post. And this id that was generated will appear in the Code field.

* I thought about doing a query and get the last id of the database, but I'm afraid this processing time will get the id generated by another user.

    
asked by anonymous 27.08.2018 / 20:39

1 answer

0

Place a (click) on the button calling the post, and then you assign the searched id in the variable that is your ngModel in the HTML page

.then (response = >    response = response.json ();    this.id = response.id;  })

Put a loading while going to the server and every time you turn on the new one and enter the method to make the post always clears the ID, not to run the risk of using the previous one.

    
29.08.2018 / 22:04