isOdd = new BehaviorSubject(false);
private _destoyed = new Subject<void>()
ngOnInit(): void {
this.nestedFc.valueChanges
.pipe(
takeUntil(this_destroyed),
map((value: any) => value % 2 !== 0)
)
.subscribe((odd) => {
this.isOdd.next(odd);
});
Front :
<span *ngIf="(isOdd | async) as value"> {{value}}</span>`
Dont forget to next into complete _destroyed on ngDestroy.
cdr.detectChanges() isn't best way to fix this.
And with this behaviorSubject impl, you can add this one (Optional but better perf) :
changeDetection: ChangeDetectionStrategy.OnPush,