Reputation: 1
I'm using Angular and Twig. Is there a way I can call an Angular function called initItems in my html like inside a
{% for post in posts%} //twig
<% verbatim %>
{{initItems(post)}} //angular
<% endverbatim %>
{% endfor %}
when post is a twig variable? Inside my initItems function in my controller, post is showing up as undefined.
Upvotes: 0
Views: 1350
Reputation: 4397
What you need to do is first changing the start and end interpolation for AngularJS to something else like
angular.module('myApp', []).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
Now you can do combine it with your twig
{% for post in posts %} //twig
<% verbatim %>
{[{initItems( {{ post }} )}]} //angular start with {[{ and end with }]}
<% endverbatim %>
{% endfor %}
You can also check this link for more info
Upvotes: 1