Angularjs on a symfony2 application

前端 未结 15 1744
面向向阳花
面向向阳花 2020-12-12 09:55

I\'m working on a SF2 application that uses a lot of javascript on the front end.

SF2 provides me a good way of building a nice REST app, manage my database with doc

15条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 10:57

    I have used the following code to change the AngularJS delmiters

    Coffeescript:

    # Change the angular delimiters for twig compatability
    # and load module with ngResource
    WAFapp2 = angular.module("WAFapp2", ['ngResource'], ($interpolateProvider) ->
      $interpolateProvider.startSymbol "{[{"
      $interpolateProvider.endSymbol "}]}"
    )    var WAFapp2;
    

    or Javascript:

    var WAFapp2;
    
    WAFapp2 = angular.module("WAFapp2", ['ngResource'], function($interpolateProvider) {
      $interpolateProvider.startSymbol("{[{");
      return $interpolateProvider.endSymbol("}]}");
    });
    

    then at the top of my layouts:

    
    
      
    

    then later in the body tag section of the html I can use:

      {% for item in seq %}
    • {[{ item }]}
    • {% endfor %}

    I think this keeps things cleaner, and allow easy mixing of twig and angular tags. This seems to work well for me.

提交回复
热议问题