Miguel_Velazkez
Miguel_Velazkez

Reputation: 180

Angularjs and PHP for CRUD operations

I have tried to look for tutorials on this but nothing simple and to the point...

Could anyone give me an example or link me to a tutorial on how to post data with angularjs to a php page?

And also with angularjs call a php file to get data in order to display a list of lets say a phonebook.

How can this be done with angularjs? I can do all this with php but i want to know how to do it with Angularjs to visualize and call php files and those PHP files would read/write on the db.

I want to use plain php(no php frameworks for now).

Thanks

Upvotes: 1

Views: 7875

Answers (3)

JoyGuru
JoyGuru

Reputation: 1833

After a long search, I've found a simple and best guide for AngularJS beginners. This example AngularJS application contain the following functionalities.

  • Fetch data from the database using PHP & MySQL, and display data using AngularJS.
  • Add data to the database using AngularJS, PHP, and MySQL.
  • Edit and update data using AngularJS, PHP, and MySQL. Delete user from the database using AngularJS, PHP, and MySQL.

If you are looking for a simple AngularJS application with step-by-step guide, must check this tutorial - AngularJS CRUD Operations with PHP and MySQL

Upvotes: 0

Gonz
Gonz

Reputation: 1219

You can do it making in PHP a couple of RESTfull services for the CRUD operation, for this you can use a Framework like Slim.

Then in AngularJs you can make a service like this for access the data:

app.factory('phoneService', ['$resource',
    function ($resource) {
        return $resource('../app/phone/:id',{id : '@id'},
            { 'findOne': { method: 'GET', params : {id : '@id'}}, isArray:false },
            { 'delete' : { method: 'DELETE', params : {id : '@id'}}, isArray: false },
            { 'save' : {method: 'POST', params : {id : '@id'}}, isArray: false }
        );
    }
]);

Upvotes: 1

Related Questions