0

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.

1

1 Answer 1

1

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

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

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.