0

Hi guys, I'm fairly new to angularjs 2 (I've only used 2) and I have a small application with a form. Currently I'm able to get the form data as an objects and print it to the console.log,

onSubmit(form: any):void{
       console.log(form);
   }

producing this:

Object {author: "Author test", title: "Title test", location: "Location test", medium: "Medium test", notes: "Notes test"}

but what I want to do now is to push that data to a mysql database. I have no idea what needs to be done, so I'm doing a bit of reading here and there, but I have to say I didn't find that much useful info: often they do it in angularjs rather than angularjs 2, so I'm not sure that applies to me. So, generally speaking, what do I need? Do I need to convert the object to Json or is it good to go as it is? If you guys have any suggestions or links for me to read, then please fire away
cheers

2
Contributors
2
Replies
26
Views
2 Weeks
Discussion Span
Last Post by Violet_82
0

Is this a mobile app or running ina browser?
If a mobile app you'll need to make an HTTP call to an endpoint to pass the data through so the server has the data to work with. From there how you proceed will depend on which language/platform you are using (C#, Jave, Node, etc).

A little more information about your setup would help.

0

It will be running in a browser.
So, here are a few more details.
The application is essentially meant to allow users to input books (Title, author and a few more fields) using a form and when the form is submitted all that data go to a database (mySql).
Currently I have only the frontend part, done entirely in angularjs 2.
I've never really stored any application data in a database before, so I'm really not sure what approach to take.
I've done more readings since after this post, and it turns out that, as you're pointing out, I need another layer, something like a webservice that takes the data from my application - which is now in Json - and sends it to the database.
After that I will have to retrieve that data too, but one thing at the time, let's think about how to send it and store it to the database first.
If you want to have a look at some code it's all in here https://github.com/Antobbo/Books-Proj-last/tree/master/src/app, if you want some specific bits, please do let me know

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.