0

I've recently started playing around with AngularJS and Node.js and I'm having a bit of trouble figuring out where exactly to place my node-mysql connection block. I have my app split up into HTML and JavaScript files for each separate page and each JavaScript file holds the config and controller blocks for the respective HTML page. If I want my app to connect to a MySQL database, where do I put the connection block? My initial thought was to put it in app.js, but then how would the other pages utilize that connection as well? Any help is greatly appreciated!

2
  • Welcome to StackOverflow and thanks for your question. Hope to see you around. You have some code to show us? This will help to provide an answer. Commented Dec 15, 2015 at 0:02
  • Put it in a factory service. docs.angularjs.org/guide/services Commented Dec 15, 2015 at 0:41

1 Answer 1

0

I assume you're using Node as your server in this case, you'll want your node-mysql information to be somewhere in your server code.

2
  • Do I use this server file as an export to be used in the other js files? Commented Dec 15, 2015 at 18:00
  • It seems you are a bit confused as to the relationship between your client(Angular) code and your server(Node) code. I'd recommend taking a look at a quick example: scotch.io/tutorials/… Commented Dec 15, 2015 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.