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?

1

2 Answers 2

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.

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

1 Comment

@Maerlyn could you please post solution example for problem mentioned above.
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.

1 Comment

It's not "my" path function, but it's a Symfony 2 function, see the documentation here : symfony.com/doc/2.3/book/templating.html#linking-to-pages Thx for the help anyway

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.