我之前使用过asoc/assetic-angular-js-bundle (GitHub),当它与资产过滤器配置一起使用时,意味着所有部分和脚本都被合并到一个文件中。
他们的 github 页面说要在你的 twig 模板中使用以下内容..
{% javascripts filter="angular"
'@BundleName/Resources/views/aTemplate.html.ng'
'@BundleName/Resources/views/fooTemplate.html.ng'
'@BundleName/Resources/views/moarTemplates/*.html.ng'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
但是如果你使用..
// app/config/config.yml
assetic:
filters:
angular:
apply_to: "\.ng$"
resource: %kernel.root_dir%/../vendor/asoc/assetic-angular-js-bundle
/Asoc/AsseticAngularJsBundle/Resources/config/assetic.xml
// This is all one line
// Not sure why this was needed, I vaguely remember
// assetic not being able to find to config
然后你可以像这样在你的 twig javascripts 部分调用你的部分..
{% javascripts
'@BundleName/Resources/views/angular-app.js'
'@BundleName/Resources/views/angular-controllers.js'
'@BundleName/Resources/views/some-other-stuff.js'
'@BundleName/Resources/views/aTemplate.html.ng'
'@BundleName/Resources/views/fooTemplate.html.ng'
'@BundleName/Resources/views/moarTemplates/*.html.ng'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
然后我想您可以将上述内容包含在您希望它显示的一个树枝视图中,也可以将其包含在您的所有模板中(取决于您希望如何处理脚本缓存以及不包含的内容)和只需使用常规的 ng-view UserListController 类型标签调用它即可。
对不起,如果这与您的要求无关。在我开始写这篇文章的时候,它很有道理,但是我怎么看它这么多,看起来我刚刚走开了一个完整的切线。