I have designed a database which I want to connect to an angular 2 app that I am building. I want to know how to get or update data from a sql database into my application .
2 Answers
Angular 2, being a client-side framework, does not care how you get data from your SQL database into the app. This data retrieval will be the job of your server. While you have many options for a server, Nodejs is fairly popular. You would then use Angular 2 services to move data between your Angular 2 client-side app and your server.
Comments
Just to give a option, NOT taking in consideration if this is a smart way or not... just an option:
You could use PHP if e.g working with MySQL. More info here Integrating Angular 2 with PHP
Example to retrieve data from table:
PHP:
<?php
// more code here...
$query = "SELECT something FROM table";
// more code... e.g perform query...
echo json_encode($data);
?>
Angular 2 service:
getData(){
return this.http.get('pathToPHPscript')
.map((res: Response) => res.json())
}