问题
I want to use angular with symfony2. To do so it should be possible to load a template from a reference like this:
<div ng-include="/link/to/template.html"></div>
The loading is the part of angular. We just have to provide a path to the template. The template should not be rendered with twig. Is this possible with symfony?
回答1:
Simple make a template without twig tags, and a route for it to load via ajax. No controller is required
my_template:
path: /path/to/template
defaults:
_controller: FrameworkBundle:Template:template
template: 'AcmeBundle:Angular:template.html.twig'
More infos: http://symfony.com/doc/current/cookbook/templating/render_without_controller.html
来源:https://stackoverflow.com/questions/18081845/reference-a-static-template-in-symfony2