Twig 中的 AngularJS 组件

标签 angularjs symfony loops variables twig

我在使用 twig 作为模板引擎的 symfony 项目中集成了 AngularJS。

但是当谈到使用循环时,我的模板崩溃了:

<md-item ng-repeat="{{ '{%item in menu%}' }}">
    <a>
      <md-item-content md-ink-ripple layout="row" layout-align="start center">
        <div class="inset">
            <ng-md-icon icon="{{ '{{item.icon}}' }}"></ng-md-icon>
        </div>
      </md-item-content>
    </a>
</md-item>

我的控制台打印:

'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression

那么有什么好的方法可以在 Twig 中使用 angularJS 循环/变量等吗?

谢谢和问候!

最佳答案

可能是 AngularJS 语法的问题,绝对不是 Twig 的问题。使用 twig 和 Angular 1.4.5 的标准语法进行测试。这应该有效:

<md-item ng-repeat="item in menu">
    <a>
        <md-item-content md-ink-ripple layout="row" layout-align="start center">
            <div class="inset">
                <ng-md-icon icon="{{ '{{item.icon}}' }}"></ng-md-icon>
            </div>
        </md-item-content>
    </a>
</md-item>

关于Twig 中的 AngularJS 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33856614/

相关文章:

css - 在 AngularJs 中创建选项卡

html - 创建水平滚动和环绕元素

javascript - Jquery each through <a> 只给我 href

angularjs - 如果 ng-repeat 逻辑包含在 ng-if 中,它是否会触发

javascript - Highcharts - 灰色图例中的唯一标题

php - Symfony2 和 Selectize.js : Clearest way to persist new items in entity field type?

symfony - 在 Symfony 2 中设置索引路由

symfony - 使用 symfony 创建自定义用户提供程序

C -- 使用循环和索引填充 char * --- 不工作

excel - 编译错误: loop without do. But Do is in the code what is wrong?的代码