Is binding to an Observable<enum>
possible like this in Angular?
<a [ngClass]="{selected: (mapToolBarMode$ | async) === 0 }" />
or
<a [ngClass]="{selected: (mapToolBarMode$ | async) === MapMode.Pan }" />
where mapToolBarMode$
is the observable
It doesnt seem to do anything as the observable mutates.
I think it could be to do with the value not being available in the constructor, if I do this it works, but I dont really want to do that for every value in the MapMode enum:
private mapModes: typeof MapMode = MapMode;
private isPanSelected = true;
ngOnInit() {
this.mapToolBarMode.subscribe(v => {
this.isPanSelected = (v === this.mapModes.Pan);
})
}
...
[ngClass]="{selected: isPanSelected }"
Update turns out this was to do with legacy code calling angular components. those calls need to run under the context of an ngZone, otherwise there's no cycling