You can provide an endpoint using apache and php to get this data from your own server:
$http.get('/endpoint', function () { ... });
You can also do something, sometimes called “loading” data into the DOM. This works fine - I usually do this to ensure that the first page of the application loads with a single page, without requiring waiting for the source data. Everything for loading the first page is configured on the server and is displayed on the page for the collection application without making further requests:
To do this, you can create a collection in a window or global area as follows:
window.myPostData = "<?php echo $data; >";
Then in your application, you can usually expect that the window object (or any global variable) will be available in the browser at any time, so it will be available as follows:
app.controller("PostsCtrl", function($scope) { var posts = window.myPostData; });
However, you probably also want to access new data, so you are likely to try something like this:
// If $data is empty, set myPostData to false. window.myPostData = <?php echo empty($data) ? 'false' : $data; >; ... app.controller("PostsCtrl", function($scope, $http) { var posts = window.myPostData; // Set myPostData to false so future use of this controller during this // request will fetch fresh posts. window.myPostData = false; // Now if we didn't bootstrap any posts, or we've already used them, get them // fresh from the server. if (!posts) { $http.get('/endpoint', function() { ... }); } });
Keep in mind, if you don’t have an understanding of how to configure the endpoint using apache and php, you will only need to load the data into a window or global variable. This is not perfect, but it will work.