title: Passing a php variable to angular
body: <p>I am building a webapp and I'm using angular for the first time. I tried yesterday to get data from an API but it will not work in Angular cause of cross origin resource restrictions. Lucky I can get the json date over a simple CURL request in PHP. </p>
  
  <p>So here I am now. I have the JSON Data in a PHP Variable and want to use this data in my Angular Application. How can I achieve that? Is there a way to pass the data directly to angular? Or should i create a json file with php and then load it into my funcion? What suggestions do you have? </p>
  
  <p>I want to fill the $scope.posts with the content of the php variable $content.</p>
  
  <p>Here's the php code: </p>
  
  <pre><code>&lt;?php
  
  
          /* gets the data from a URL */
          function get_data($url) {
          $ch = curl_init();
          $timeout = 5;
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
          $data = curl_exec($ch);
          curl_close($ch);
          return $data;
          }
  
          $returned_content = get_data('http://fingerzeig.ch/api/agenda/list');
          $content = json_decode($returned_content);
          //print_r ($content);
  
          //Get first title
          //$firstitle = $content[0] -&gt; ID;
  
          //print_r($firstitle);
  
  
  
          ?&gt;
  </code></pre>
  
  <p>The Angular code: </p>
  
  <pre><code>//MYAPP
  
  var app = angular.module("MyApp", []);
  
  
  app.controller("PostsCtrl", function($scope, $http) {
    $http.get(' WHAT SHOULD GO HERE? ').
      success(function(data, status, headers, config) {
       console.log("success!");
       console.log(data);
        $scope.posts = data;
      }).
      error(function(data, status, headers, config) {
        // log error
      });
  });
  </code></pre>