Let's say we have a collection of entities, like articles
and we need to generate a list of it with the corresponding urls to a particular article.
If we didn't use angularjs then a list item could look like (twig):
<li>
<a href="{{ path('article', {'id': article.id}) }}">{{ article.name }}</a>
</li>
But, because of I'm using angularjs - I cannot use this solution since I iterate over articles on client side and don't have access to server side url generator.
I've came into 2 conclusions:
(the one I use) I generate the url with id: 0
and then in angularjs controller just replace 0
which acts as a placeholder with an actual id value
To generate an array of urls serverside and pass it into angularjs
I don't like any of the solutions much though.
Are there better options?
You could use the Friends of Symfony bundle FoSJsRoutingBundle.