[英]emitted value from an event can not be received
the distance-measurment-parameters.component is a child in site-map.component. distance-measurment-parameters.component 是 site-map.component 中的一个子项。 The method hideWindowOverlay() in distance-measurment-parameters is invoked when a window is closed and it emits and event as shown below.
当 window 关闭并发出如下所示的事件时,将调用距离测量参数中的 hideWindowOverlay() 方法。 the log statement in the hideWindowOverlay() is displayed which indicates that the event is emitted.
显示 hideWindowOverlay() 中的日志语句,表示事件已发出。
in the component site-map.component, i listen or subscribe to the event 'evtEmitterOnDistanceMeasurementWindowClosed' as follows and as shown in the code below在组件site-map.component中,我监听或订阅事件'evtEmitterOnDistanceMeasurementWindowClosed',如下所示,如下面的代码所示
(evtEmitterOnDistanceMeasurementWindowClosed)=onDistanceMeasurementWindowClosedEvtReceived($event)/>
The problem is, the mehtod onDistanceMeasurementWindowClosedEvtReceived() is never invoked, hence the event is not received.问题是,永远不会调用方法 onDistanceMeasurementWindowClosedEvtReceived(),因此不会收到事件。
please let me know how to subscribe to the event 'evtEmitterOnDistanceMeasurementWindowClosed' correctly and how to make the method 'onDistanceMeasurementWindowClosedEvtReceived' method is invoked请让我知道如何正确订阅事件“evtEmitterOnDistanceMeasurementWindowClosed”以及如何调用“onDistanceMeasurementWindowClosedEvtReceived”方法
in site-map.html :在站点地图.html 中:
<clr-toggle-wrapper *ngIf="showMeasureDistance">
<input type="checkbox" clrCheckbox (change)="toggleDistanceMeasurementOverlay()" [(checked)]="showMeasureDistanceOverlay"
(evtEmitterOnDistanceMeasurementWindowClosed)=onDistanceMeasurementWindowClosedEvtReceived($event)/>
<label >
{{ "SITE.MEASURE_DISTANCE" | translate }}
<button class="btn btn-sm btn-icon" (click)="showInformation('SERVICE_MEASURE_DISTANCE')">
<clr-icon shape="help-info" class="is-solid"></clr-icon>
</button>
</label>
</clr-toggle-wrapper>
distance-measurment-parameters.component :距离测量参数。组件:
//declaration of the event emitter
@Output("evtEmitterOnDistanceMeasurementWindowClosed")
evtEmitterOnDistanceMeasurementWindowClosed: EventEmitter<boolean> = new
EventEmitter<boolean>();
hideWindowOverlay() {
//throw new Error('Method not implemented.');
this.showWindow = false;
this.evtEmitterOnDistanceMeasurementWindowClosed.emit(true);
console.log("hideWindowOverlay: emits event this.evtEmitterOnDistanceMeasurementWindowClosed.emit(true)");//log here are displayed
}
in site-map.component :在 site-map.component :
onDistanceMeasurementWindowClosedEvtReceived(event: boolean){
this.toggleDistanceMeasurementOverlay();
console.log("onDistanceMeasurementWindowClosedEvtReceived: ");//log are not displayed
}
As I can see you're trying to listen to a evtEmitterOnDistanceMeasurementWindowClosed event from an input element, but input hasn't such event emitter.正如我所看到的,您正在尝试从输入元素收听 evtEmitterOnDistanceMeasurementWindowClosed 事件,但输入没有这样的事件发射器。 Try to call onDistanceMeasurementWindowClosedEvtReceived method on some of the built-in input events - onchange eg
尝试在某些内置输入事件上调用 onDistanceMeasurementWindowClosedEvtReceived 方法 - onchange 例如
Or use [(ngModel)] like this或者像这样使用 [(ngModel)]
<input [(ngModel)]="value"
(ngModelChange)="onDistanceMeasurementWindowClosedEvtReceived($event)"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.