【问题标题】:Using local variable of ngFor in child elements在子元素中使用 ngFor 的局部变量
【发布时间】:2016-03-07 15:25:58
【问题描述】:

我想显示局部变量theme 的属性,例如theme.name

这就是我的*ngFor 的样子

<ul>
   <li *ngFor="#theme of themes">
      <span>theme.name</span>
   </li>
</ul>

我也尝试使用{{theme.name}},但也没有用。

【问题讨论】:

  • “不起作用”不是很有帮助。如果theme 有一个name 属性{{theme.name}} 有效。

标签: typescript angular ngfor


【解决方案1】:

如果

{{theme.name}}

不行,然后

{{theme?.name}}

可能会

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    相关资源
    最近更新 更多