Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ngFor在ngFor中单击设置活动类?_Angular - Fatal编程技术网

Angular ngFor在ngFor中单击设置活动类?

Angular ngFor在ngFor中单击设置活动类?,angular,Angular,我在ngFor中有ngFor,我想要的是在点击第二个ngFor时设置活动类。有什么建议我怎么做?? 我试图添加selectedItem==item,但它不起作用,我认为正因为如此items[position],这是因为您要选择主数组“Positions”中的项,您必须更改单击事件的代码以发送到当前位置,而不是项目。像这样的 <div *ngFor="let position of positions" [ngClass]="{active : position===selected.r

我在ngFor中有ngFor,我想要的是在点击第二个ngFor时设置活动类。有什么建议我怎么做??
我试图添加
selectedItem==item
,但它不起作用,我认为正因为如此
items[position]
,这是因为您要选择主数组“Positions”中的项,您必须更改单击事件的代码以发送到当前位置,而不是项目。像这样的

 <div *ngFor="let position of positions" [ngClass]="{active :  position===selected.row }">


    <div *ngFor="let item of items[position], let i = index"   class="flow-one-item" (click)="selectItem(item)"> </div> </div>


你能用你的代码做一个小的StackBlitz吗?这会更容易得到帮助吗?从这样不清楚的描述中很难回答
<div *ngFor="let position of positions" 
     [ngClass]="{active :  position===selected.row }">


     <div *ngFor="let item of items[position], let i = index"     
           class="flow-one-item" (click)="selectItem(position)"></div> 
</div>