[英]Ng-container not showing when clicking button
This is my portion of html code:这是我的 html 代码部分:
<div>
<button
type="button"
class="add-emp-btn"
*ngIf="!addEmployeeBtnClicked"
(click)="onEmpBtnClicked()"
[disabled]="newProjectForm.invalid"
>
Add Employees
</button>
<ng-container *ngIf="addEmployeeBtnClicked" formArrayName="employees">
<div *ngFor="let employeesControl of getControls(); let i = index">
<label for="userName">Insert one or multiple Users Names to submit</label>
<input type="text" [formControlName]="i"/>
<div class="width-divider"></div>
<button type="button" class="goto-add-emp-btn">Cancel</button>
</div>
</ng-container>
</div>
The button clicked logic works because if i put the *ngIf in the div where the *ngFor now is, the button is hidden and the other 3 elements are shown.按钮单击的逻辑有效,因为如果我将 *ngIf 放在 *ngFor now 所在的 div 中,则隐藏按钮并显示其他 3 个元素。 But of course i need the *ngFor there, that's why i wrapped everything with ng-container.
但是我当然需要 *ngFor 那里,这就是为什么我用 ng-container 包装所有东西。 I did this already few lines of code above and worked in that case.
我在上面已经做了几行代码,并在这种情况下工作。 I must be missing something trivial.
我一定错过了一些微不足道的东西。
Tl;dr: when Add Employees button is clicked, it should disappear and the ng container with the lable, input text and Cancel button, should appear Tl;dr:当单击添加员工按钮时,它应该消失,并且带有标签、输入文本和取消按钮的 ng 容器应该出现
I copied this code, changed a few things because I don't have your surround code and it works.我复制了这段代码,改变了一些东西,因为我没有你的环绕代码,它可以工作。 Things to check:
检查事项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.