1
我愿意仅使用ngIf显示特定元素;但是,由于某种原因,它不起作用。Angular2 - * ngIf:如何显示特定元素?
问题:当我点击仅显示特定元素时,所有其他元素都显示出来!
的代码:
HTML(元素从一个异步请求采取)
<ion-col *ngFor="#finalFormat of elements">
<div *ngIf="currentElement">
<div>Show this element</div>
</div>
<div (click)="showThis(finalFormat.elementName)" *ngIf="!currentElement">CLICK TO SHOW</div></ion-col>
JS:
showThis(element){
if(this.currentElement === element){
return;
}
this.currentElement = element;
}