0
我想检测一下,如果我点击里面的组件,但我有一些地方,我用ngIf来显示或隐藏一些元素,这就是问题,因为它看不到那个元素,我现在得到错误。任何建议如何解决这个问题?我有侧边栏组件。侧边栏里面我有这样的:组件内检测是否对某些元素有ngIf?
<default-block head="Podaci o korisniku" class="z-col-24" block="blockgroup" [(visible)]="isCustomerVisible || getFromModal" [mainBlock] = "isVisibleBackCa" [additionalItems]="true" (buttonClick)="getFromHistory()"
(openModal)="showModal($event)" [ngClass]="{disabledCa: disabled}">
<div default-block="body" class="contact-body pointer">
<div class="contact-body-wrapper" dnd-draggable [dragData]="customerGeneralInfo" (onDragStart)="dnd.set(true);" (onDragEnd)="dnd.set(false)" >
<span class="inline" *ngIf="customerGeneralInfo?.customerinfo?.lastname">
<div class="z-inputs" >
<label>Korisnik</label>
<span disabled class="textarea"> {{customerGeneralInfo?.customerinfo?.lastname}} </span>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.customertypeName">
<div class="z-inputs">
<label>Tip</label>
<input class="readonly" [ngModel]="customerGeneralInfo?.customertypeName" type="text" disabled>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.customerstypeName">
<div class="z-inputs">
<label>Podtip</label>
<span class="textarea">{{customerGeneralInfo?.customerstypeName}}</span>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.parentName">
<div class="z-inputs">
<label>Parent</label>
<span class="textarea" disabled>{{customerGeneralInfo?.parentName}}</span>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.headName">
<div class="z-inputs">
<label>Nosilac hijerarhije</label>
<span class="textarea" disabled >{{customerGeneralInfo?.headName}}</span>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.activationdate">
<div class="z-inputs">
<label>Datum aktivacije korisnika</label>
<input class="readonly" [ngModel]="customerGeneralInfo?.activationdate | date:'dd.MM.yyyy'" type="text" disabled>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.terminationdate">
<div class="z-inputs">
<label>Datum isključenja korisnika</label>
<input class="readonly" [ngModel]="customerGeneralInfo?.terminationdate | date:'dd.MM.yyyy'" type="text" disabled>
</div>
</span>
<span class="inline" *ngIf="customerGeneralInfo?.description">
<div class="z-inputs">
<label>Razlog isključenja korisnika</label>
<input class="readonly" [ngModel]="customerGeneralInfo?.description" type="text" disabled>
</div>
</span>
</div>
</default-block>
我有这个<default-block>
在那里我有与ngIf作品可见真或假的多。现在当我点击边栏上的somem meni时,我会在边栏组件中显示该块。问题是当我在这些块之间切换时,因为它们是隐藏的event.target是假的,然后它总是检测到“外部”事件。
如果我已经在该组件上,该如何帮助我? – None
感谢您的更新。乍一看,尝试使用* ngIf而不是Visible属性:这是[不推荐](http://angularjs.blogspot.hu/2016/04/5-rookie-mistakes-to-avoid-with-angular。 HTML)在Angular中了。也许不会混合它们将解决问题。 – ForestG
可见只是输入,然后在该组件上使用隐藏类,我隐藏或显示..与显示:没有像ngIf一样 – None