Miguel_Velazkez Miguel_Velazkez - 5 months ago 34
PHP Question

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).



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 }