0

I need to make an app with Ionic/angularJS, I used that two technologies before, but now I need to use a database system to save data on a external server in the web, angular can work with a mysql database with a host?

In case of you can do it, if you can link a good documentation it will help too :D

    2 Answers 2

    1

    The thing is; you can't connect Ionic to MySQL directly. No, there's no workaround, no magic involved, it's just not the way this is supposed to work. Ionic works on top of Angular and Angular is a frontend framework.

    However, the way you should do it is that you basically create a (RESTful) API on your server side.

    Most likely this will be made with PHP which will talk directly to MySQL and query it.

    After you write your (RESTful) API (you'll need to invest some time to learn how to do it) then you can consume it through your services in Angular by using Angular's $resource object.

    Sure, this is not a step by step answer, and it seems you're just starting in this area, so you have some learning to do on your part (REST, RESTful, $resource, services...), but I wish you good luck and if you'll have any more specific questions, don't hesitate to ask them.

    2
    • ok so if I undertand it good, I will need to create a .php file to connect to the database and get all data, and query it to create an API, and then with that api with angular i can get data with $http, correct?CommentedApr 14, 2016 at 11:16
    • Yes. That's essentially correct. Though, don't feel discouraged if you land into a lot of material on how to do this. You'll figure it out eventually, and then you'll ask yourself 'how have I lived without this?'. Good luck!
      – Nikola
      CommentedApr 14, 2016 at 11:47
    0

    You can't use your MySQL-Database with Angular directly. You'll need an application that provides a REST API and connects you client with the database. If you don't want to code that yourself you could use something like this: https://www.npmjs.com/package/mysql-to-rest or https://github.com/mevdschee/php-crud-api. Keep in mind that there might be security issues if you allow operations like POST and DELETE.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.