Angular 2 and MySQL concepts

前端 未结 2 779
面向向阳花
面向向阳花 2020-12-16 04:56

Are there recommended concepts how to access MySQL from an Angular 2 application?

I\'m new to Angular and Typescript. I found and installed the node-mysql

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 05:32

    Communication directly from Angular to Mysql is bad practice (in most cases). Angular runs client side and exposing mysql to it allows for anybody to run arbitrary SQL statements.

    The solution is to create an intermidate server. It could run nodejs, to which you can then import node-mysql. The nodejs server could expose a REST api which your angular 2 application consumes.

提交回复
热议问题