【发布时间】:2018-12-24 17:30:34
【问题描述】:
我正在尝试做一些应该很简单的事情: 我想在 *ngFor 中执行一个函数。该函数返回一个对象。我想在一种“let”语句中设置对象,这样我就可以在 HTML 中使用它的属性:
<div *ngFor="let productGroup of getproductGroupBySomeVariable(variable)">
<!-- This is where I need to set a variable with the output of
the getProductBySomeProperty function-->
<div *ngLet="'{{getProductBySomeProperty(productGroup.someproperty)}}'
as myVar" class="ui-g">
<!-- Here I want to use and display the properties of the
object created by the function above-->
<span>{{myVar.property1}} </span>
<span>{{myVar.property2}} </span> etc....
</div>
</div>
【问题讨论】:
-
你不会想在模板中使用这样的函数。它将在每次更改检测时触发。
-
@AJT_82 - 你是对的 - 我把它全部收集成组件网中的数据结构