0

I used the code from http://angularjs.org/ (Wire up a Backend) Here in project.js

angular.module('project', ['firebase']).
 value('fbURL', 'https://angularjs-projects.firebaseio.com/').
 factory('Projects', function(angularFireCollection, fbURL) {
 return angularFireCollection(fbURL);
 }).
 config(function($routeProvider) {

I used this code in my web page. Instead of https://angularjs-projects.firebaseio.com/ url i want to use my url i.e http://test.com/test.php. But it didn't work.

Also i want to know in my php file in which format the out put should be? Do you need to echo the content in php file or use the return command? Please give suggestion. I have searched a lot. I couldn't find the solution.

1
  • Its not working. angular.module('project', ['firebase']). value('fbURL', 'test.com/process.php'). factory('Projects', function(angularFireCollection, fbURL) { return angularFireCollection(fbURL); }). Shall we need to remove firebase? Commented Aug 30, 2013 at 10:39

2 Answers 2

1

I think in firebase url https://angularjs-projects.firebaseio.com/ they are returning the response from their back-end service. That is why it didn't worked for you even if you changed the URL.

And answer to your second question;

If you make a call to your back-end service its better to have a json response style from your PHP and you don't have to use any return command for that. Instead you should echo your contents.

For example in your PHP file if you are getting the results as an array you can give back the response to the angular application as;

echo json_encode($result_array);

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

0

I think you should separate backend and frontend and treat them as two separated application. Both apps should communicate with each other by sending ajax request (front) and respone data in json format (backend). In my opinion it's the best way to handle this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.