Angularjs on a symfony2 application
Solution 1:
I think Symfony2
can perfectly work well with AngularJS
. Proof is I'm making an API on one side using Symfony, and a web app on the other side with AnglularJS.
Moreover, for some reasons I generate my views in my web app with Twig
. I simply embed angular's curly braces in a twig {% verbatim %} {% endverbatim %}
statement each time I need to use Angular in my views.
Solution 2:
As of Twig 1.12 the raw tag was renamed to verbatim:
{% verbatim %}
<ul>
{% for item in seq %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endverbatim %}
Everything in-between won't be parsed by the Twig Engine and can be used by AngularJS.
Though I'd recommend changing the AngularJS delimiters. Otherwise it can be hard to distinguish between Twig and AngularJS code when looking at your templates.