每个元素的删除/向下元素(Angular 4)



我想为数组中的每个元素创建drop/down元素:

  <div *ngFor="let hotel of hotels">
    <div>Photo</div>
    <div>{{ hotel.name }}</div>
    <div><button (click)="changeIsShohToTrue()" type="button" class="btn btn-default btn"><i class="glyphicon glyphicon-align-justify"></i></button></div>
    <div *ngIf="isShow">Additional information</div>
  </div>  

主要想法是单击按钮系统删除/向下div,并使用其他信息单击。

在我的实现打开/关闭所有其他DIV中,如何仅用于单击元素的DROP/DOWN DIV?

isShown放在每个酒店对象上,这意味着您将hotel.isShown =true设置在功能中,然后相应地更改条件:*ngIf="hotel.isShown"

您可以将布尔字段" isshowaddinfo"添加到酒店模型,更改

<div *ngIf="hotel.isShowAddInfo">Additional information</div>

,然后将OnClick事件处理程序更改为

(click)="changeIsShohToTrue(hotel)

在处理程序中,只需切换" isshowaddinfo"。

最新更新