1

The {[{project.id}]} AngularJS variable is not interpreted by twig in the path function. This my code:

<section class="main" ng-controller="PaginationDemoCtrl">
    <table class="table table-striped table-hover table-responsive">
        <thead>
            <tr>
                <th>{% trans %}Id{% endtrans %}</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="project in filteredProjectList">
                <td>
                    <a href="{{ path('project_show', { 'projectId': {[{project.id}]} }) }}">
                        {[{ project.id }]}
                    </a>
                </td>
            </tr>
        </tbody>
    </table>

    <pagination
            total-items="totalItems" 
            items-per-page="itemsPerPage"
            ng-model="currentPage" 
            ng-change="pageChanged()">
    </pagination>
</section> 

<script>
    angular.module('myModule', ['ui.bootstrap']);
    angular.module('ui.bootstrap').config(function ($interpolateProvider) {
        $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
    });
</script>

Have you got a trick to fix this problem?

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
Nicolas Talichet
  • 309
  • 3
  • 16
  • http://stackoverflow.com/questions/13671701/angularjs-twig-conflict-with-double-curly-braces – Cerad Dec 30 '14 at 21:14

2 Answers2

2

Angular is client-side, twig is server-side, so you cannot call twig's path function from angular.

If you want to generate routes on the client, look into FOSJsRoutingBundle.

Maerlyn
  • 33,687
  • 18
  • 94
  • 85
0

Not sure what you are trying to do here, but you don't need to interpolate product.id again. This should be ok, but it would help to see your path function:

<tr ng-repeat="project in filteredProjectList">
    <td>
        <a ng-click="path('project_show', { 'projectId': project.id })">
            {[{ project.id }]}
        </a>
    </td>
</tr>

I'm assuming here that path is a function defined on the controller's $scope.

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
  • It's not "my" path function, but it's a Symfony 2 function, see the documentation here : http://symfony.com/doc/2.3/book/templating.html#linking-to-pages Thx for the help anyway – Nicolas Talichet Dec 30 '14 at 21:37