1

Im new to Angular.JS and just wondering if it is possible to write mysql queries in angularjs? I would like this as I am trying to create a messaging system in which I query the database and get the information live to the webpage.

Any help is appreciated, hope the question is reasonable. Gab

1 Answer 1

4

That is not advisable (if possible at all) as it would defeat the purpose of Angular.

You should consume data by targeting a RESTful api/service exposed by the server. The service would handle the DB access for you and provide the data to Angular using a more portable format (e.g. JSON or XML)

  • Some of the basics of linking Angular and REST are described here
  • There are related questions on SO about exposing your particular DB flavor using REST here.

This can only be a starting point but it should give you some ideas. I will try to amend this with more info as I come across it.

Sign up to request clarification or add additional context in comments.

3 Comments

So the correct response would be to send say a $http to say php or JSON instead of inside Angular.JS?
yeah, let the server handle all communication with the database.
Thanks Ill make sure to do that!

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.