Configure angular with php server

Asked

Viewed 763 times

-1

I need to configure the angular to send data to php?

I noticed in the file: C: wamp www angular bower_components angular.js

has server settings, methods, etc.

3 answers

2

You can send the data to php using $http.post or $http.get.

    .controller('BuscaCtrl',function($scope,$http) {
            // Faz a busca no php
            $http.get('<caminho do arquivo .php>')
            .success(function(data){
                    // Pega os dados recebidos do php
                    console.log(data);
            });
    });
  • Allow me a few more questions. Where do I insert this line? . controller('Buscactrl',Function($Scope,$http) { Is Buscactrl a function? $http.get('<file path . php>') //Would it be the cakephp controller? If so, how to pass the function or action to search in the database?

  • André, I recommend reading some web tutorials on how to implement Angularjs. In Brase, this code I gave you would be in a file . js or even within the <script></script> tags of your page with the parameters that the angular requires to execute.

1

  • 1

    I think the answer lies on the boundary between "just-link" and "poor-but-valid answer". I will not vote and leave it to others, remembering that the rule is "if there was no link, the answer would be sustained?"

1


The best way to communicate with back-end servers (your PHP application) using Angularjs is by using $http.

You could give a better study in Angularjs, and Restful.

For Angularjs to study taking the course of Codeschool, for Restful look for PHP frameworks that cover the heavy work of implementation.

Good luck!!

  • If you help me, I gave a short explanation in this post: http://answall.com/questions/85570/como-persistir-um-registro-no-banco-datas-atrav%C3%A9s-de-webservice-restful-java/85594#85594 of how to configure an application using Angularjs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.