希望从异步调用中获取angular2 ngfor按钮循环的值

时间:2016-12-10 11:09:29

标签: for-loop angular asynchronous observable

我有一个来自观察者的异步for循环,它是一个数组的对象。我想知道如何在单击按钮时从该数组中获取值?

数组的对象是这样的:{topic:[" first choice"," second choice"," third choice" ]}

<button *ngFor = "let choice of (choices | async)?.Topics">
{{question}}

1 个答案:

答案 0 :(得分:1)

<button *ngFor = "let choice of (choices | async)?.Topics" 
    (click)="clickHandler(choice)">