私はこれがあります。グーグルのマップのズームイベントにngClassを使用して結合いいえマッピングし
<i [ngClass]="{'active': isGeoLocationButtonEnabled }" class="toggle fa fa-crosshairs" >
をハンドラは次のとおりです。
private onStartZoomEvent(event) {
if (event.zoom != 12) {
console.log("Current zoom level is: ", event.zoom);
this._eventAggregator.trigger(new DisableGeolocationEvent());
this.disableGeolocationButton();
}
}
次のようになりますがトリガーされるイベント:
private mapZoomChangedHandler() {
this._mapsWrapper.getMap().then((map: google.maps.Map) => {
let zoom = map.getZoom();
this._eventAggregator.trigger(new MapStartZoomEvent(zoom));
});
}
私はこのように購読しています:
this._eventAggregator.subscribe(MapStartZoomEvent, this.onStartZoomEvent.bind(this));
初めてマップズームを変更すると、ボタンが無効にならないという問題があります。 2回目にクリックすると、無効になります。私がデバッグすると、すべてが正常であるように見えます。私のブーリアンisGeoLocationButtonEnabledはfalseに設定されていますが、アクティブなクラスはそのままです(バックグラウンドカラーの強調表示です)。
呼び出されますか? –
public isGeoLocationButtonEnabled:ブール値= false;コンストラクタ内でthis.isGeoLocationButtonEnabled = false;いずれも動作しません –