如何一次只在ngFor Angular中显示一个li

时间:2018-11-12 10:14:37

标签: angular click hide show ngfor

我有下面的代码,该图标将图标显示为锚标记的一部分,单击它时,将显示下面提到的带有li标记的列表。这里的问题是因为li与单个ngFor相关联,例如,当i = 2时,li被创建两次,而当i = 3时,li被创建三次。如何一次只显示一个li并隐藏其他li。?

<div *ngFor="let person of persons; let i = index ">
    <div>{{person.name}}</div>
    <a href='#' data-target='dropdown3' class="sharebtn" (click)="shareIconClicked($event, i);"></a>
    <ul id='dropdown3' [ngClass]="{'popupShare': showPopup == true}">
        <li><a>Copy Message</a></li>
    </ul>
</div>

1 个答案:

答案 0 :(得分:2)

您可以在li标签中使用ngIf

def manager_add(request):
    print("Form is submitted successfully!")
    mname = request.POST.get("mname", False)
    dprtmnt = request.POST.get("dprtmnt", False)
    email = request.POST.get("email", False)
    phone = request.POST.get("phone", False)

    ManagerAdd = Manager(mname = mname, dprtmnt = dprtmnt, email = email, phone = phone, is_active=False) 
    ManagerAdd.save()

    return render(request,'manageradd.html')