how to specify URLs through symfony route names with restangular?
Hi,
I am new to restangular. My goal is just to try an example on symfony + angularjs + restangular.
I managed to make the example working. But, this required me to start a webserver through that command $ php app/console server:run localhost:8080
But, this is not what I am looking for. It's a symfony project and I am expecting to make trials on it with that url in my localhost: http://localhost/symfony-angular-todomvc/web/app_dev.php/TodoMVC
In fact, without running that command $ php app/console server:run localhost:8080, I am getting error telling that
GET XHR http://localhost/todos [HTTP/1.1 404 Not Found 0ms]
I solved that by specifying the setting the base URL in the that line L26 as follows:
RestangularProvider.setBaseUrl('/symfony-angular-todomvc/web/app_dev.php/');
So, my question is: "is it possible to specify the URLs when calling the API through symfony route name?" (I am asking this question to avoid setting a base url and then setting the allurl Restangular.allUrl('todos');)
Hint: Routing.generate('route_name') from FOSJsRoutingBundle could be a solution?
Thank you in advance
my question is: "is it possible to specify the URLs when calling the API through symfony route name?"
Yes:
// Include http://localhost in the URL
RestangularProvider.setBaseUrl("http://localhost/symfony-angular-todomvc/web/app_dev.php/TodoMVC");
And what about Routing.generate('route_name') from FOSJsRoutingBundle?
Is it possible?
I'm not sure what you're talking about since I'm not familiar with the library in question. Can you please elaborate?
Hi @mappedinn you can use FOSJsRouting and expose symfony's routes
Thank you @miguelplazasr for your answer.
Can you please how it would become in this case the code below?
RestangularProvider.setBaseUrl('/symfony-angular-todomvc/web/app_dev.php/');
Thanks again!